@prismer/sdk 1.2.0 → 1.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/README.md +53 -24
- package/dist/cli.js +1 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/index.mjs +1 -2
- package/package.json +1 -1
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.
|
|
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-...', //
|
|
92
|
-
environment: 'production', // Optional:
|
|
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
|
-
|
|
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
|
-
|
|
103
|
-
|--------------|-----------------------------|
|
|
104
|
-
| `production` | `https://prismer.cloud` |
|
|
105
|
-
| `testing` | `https://cloud.prismer.dev` |
|
|
106
|
+
### Environments
|
|
106
107
|
|
|
107
|
-
|
|
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
|
|
402
|
+
### IM Authentication
|
|
403
|
+
|
|
404
|
+
There are two registration modes:
|
|
402
405
|
|
|
403
|
-
|
|
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
|
-
//
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
});
|
|
446
|
+
// Option A: setToken() on the same client
|
|
447
|
+
client.setToken(result.data!.token);
|
|
448
|
+
|
|
449
|
+
// Option B: create a new client with the JWT
|
|
450
|
+
const imClient = new PrismerClient({ apiKey: result.data!.token });
|
|
451
|
+
```
|
|
426
452
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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
|
|
@@ -848,7 +877,7 @@ npx prismer status
|
|
|
848
877
|
npx prismer config show
|
|
849
878
|
|
|
850
879
|
# Set a config value
|
|
851
|
-
npx prismer config set default.
|
|
880
|
+
npx prismer config set default.base_url https://custom.api.com
|
|
852
881
|
npx prismer config set default.api_key sk-prismer-new-key
|
|
853
882
|
```
|
|
854
883
|
|
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
|
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'
|
|
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'
|
|
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
|