@prismer/sdk 1.1.0 → 1.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @prismer/sdk
2
2
 
3
- Official TypeScript/JavaScript SDK for the Prismer Cloud API (v1.0.0).
3
+ Official TypeScript/JavaScript SDK for the Prismer Cloud API (v1.1.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
 
@@ -488,7 +488,76 @@ const history = await client.im.direct.getMessages('user-123', {
488
488
  });
489
489
  ```
490
490
 
491
- Message types: `text`, `markdown`, `code`, `system_event`.
491
+ Message types: `text`, `markdown`, `code`, `system_event`, `tool_call`, `tool_result`, `thinking`, `image`, `file`.
492
+
493
+ #### Message Threading (v3.4.0)
494
+
495
+ Reply to a specific message by passing `parentId`:
496
+
497
+ ```typescript
498
+ // Send a threaded reply in a DM
499
+ await client.im.direct.send('user-123', 'Replying to your message', {
500
+ parentId: 'msg-456',
501
+ });
502
+
503
+ // Threaded reply in a group
504
+ await client.im.groups.send('group-123', 'Thread reply', {
505
+ parentId: 'msg-789',
506
+ });
507
+
508
+ // Low-level threaded reply
509
+ await client.im.messages.send('conv-123', 'Thread reply', {
510
+ parentId: 'msg-789',
511
+ });
512
+ ```
513
+
514
+ #### Advanced Message Types (v3.4.0)
515
+
516
+ ```typescript
517
+ // Tool call (for agent-to-agent tool invocation)
518
+ await client.im.direct.send('agent-456', '{"tool":"search","query":"quantum computing"}', {
519
+ type: 'tool_call',
520
+ metadata: { toolName: 'search', toolCallId: 'tc-001' },
521
+ });
522
+
523
+ // Tool result (response to a tool call)
524
+ await client.im.direct.send('agent-456', '{"results":[...]}', {
525
+ type: 'tool_result',
526
+ metadata: { toolCallId: 'tc-001', status: 'success' },
527
+ });
528
+
529
+ // Thinking (chain-of-thought)
530
+ await client.im.direct.send('user-123', 'Analyzing the data...', {
531
+ type: 'thinking',
532
+ });
533
+
534
+ // Image
535
+ await client.im.direct.send('user-123', 'https://example.com/chart.png', {
536
+ type: 'image',
537
+ metadata: { alt: 'Sales chart Q4' },
538
+ });
539
+
540
+ // File
541
+ await client.im.direct.send('user-123', 'https://example.com/report.pdf', {
542
+ type: 'file',
543
+ metadata: { filename: 'report.pdf', mimeType: 'application/pdf' },
544
+ });
545
+ ```
546
+
547
+ #### Structured Metadata (v3.4.0)
548
+
549
+ Attach arbitrary metadata to any message:
550
+
551
+ ```typescript
552
+ await client.im.direct.send('user-123', 'Analysis complete', {
553
+ metadata: {
554
+ source: 'research-agent',
555
+ priority: 'high',
556
+ tags: ['analysis', 'completed'],
557
+ model: 'gpt-4',
558
+ },
559
+ });
560
+ ```
492
561
 
493
562
  ---
494
563
 
package/dist/cli.js CHANGED
@@ -717,14 +717,11 @@ var IMClient = class {
717
717
  }
718
718
  };
719
719
  var PrismerClient = class {
720
- constructor(config) {
721
- if (!config.apiKey) {
722
- throw new Error("apiKey is required");
723
- }
724
- if (!config.apiKey.startsWith("sk-prismer-") && !config.apiKey.startsWith("eyJ")) {
720
+ constructor(config = {}) {
721
+ if (config.apiKey && !config.apiKey.startsWith("sk-prismer-") && !config.apiKey.startsWith("eyJ")) {
725
722
  console.warn('Warning: API key should start with "sk-prismer-" (or "eyJ" for IM JWT)');
726
723
  }
727
- this.apiKey = config.apiKey;
724
+ this.apiKey = config.apiKey || "";
728
725
  const envUrl = ENVIRONMENTS[config.environment || "production"];
729
726
  this.baseUrl = (config.baseUrl || envUrl).replace(/\/$/, "");
730
727
  this.timeout = config.timeout || 3e4;
@@ -735,6 +732,13 @@ var PrismerClient = class {
735
732
  this.baseUrl
736
733
  );
737
734
  }
735
+ /**
736
+ * Set or update the auth token (API key or IM JWT).
737
+ * Useful after anonymous registration to set the returned JWT.
738
+ */
739
+ setToken(token) {
740
+ this.apiKey = token;
741
+ }
738
742
  // --------------------------------------------------------------------------
739
743
  // Internal request helper
740
744
  // --------------------------------------------------------------------------
@@ -746,9 +750,10 @@ var PrismerClient = class {
746
750
  if (query && Object.keys(query).length > 0) {
747
751
  url += "?" + new URLSearchParams(query).toString();
748
752
  }
749
- const headers = {
750
- "Authorization": `Bearer ${this.apiKey}`
751
- };
753
+ const headers = {};
754
+ if (this.apiKey) {
755
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
756
+ }
752
757
  if (this.imAgent) {
753
758
  headers["X-IM-Agent"] = this.imAgent;
754
759
  }
package/dist/index.d.mts CHANGED
@@ -165,8 +165,8 @@ declare class RealtimeSSEClient extends TypedEmitter {
165
165
  type Environment = 'production' | 'testing';
166
166
  declare const ENVIRONMENTS: Record<Environment, string>;
167
167
  interface PrismerConfig {
168
- /** API Key (starts with sk-prismer-) or IM JWT token */
169
- apiKey: string;
168
+ /** API Key (starts with sk-prismer-) or IM JWT token. Optional for anonymous IM registration. */
169
+ apiKey?: string;
170
170
  /** Environment preset (default: 'production'). Sets the base URL automatically. */
171
171
  environment?: Environment;
172
172
  /** Base URL override. Takes priority over `environment` if both are set. */
@@ -716,14 +716,19 @@ declare class IMClient {
716
716
  health(): Promise<IMResult<void>>;
717
717
  }
718
718
  declare class PrismerClient {
719
- private readonly apiKey;
719
+ private apiKey;
720
720
  private readonly baseUrl;
721
721
  private readonly timeout;
722
722
  private readonly fetchFn;
723
723
  private readonly imAgent?;
724
724
  /** IM API sub-client */
725
725
  readonly im: IMClient;
726
- constructor(config: PrismerConfig);
726
+ constructor(config?: PrismerConfig);
727
+ /**
728
+ * Set or update the auth token (API key or IM JWT).
729
+ * Useful after anonymous registration to set the returned JWT.
730
+ */
731
+ setToken(token: string): void;
727
732
  private _request;
728
733
  /** Load content from URL(s) or search query */
729
734
  load(input: string | string[], options?: LoadOptions): Promise<LoadResult>;
package/dist/index.d.ts CHANGED
@@ -165,8 +165,8 @@ declare class RealtimeSSEClient extends TypedEmitter {
165
165
  type Environment = 'production' | 'testing';
166
166
  declare const ENVIRONMENTS: Record<Environment, string>;
167
167
  interface PrismerConfig {
168
- /** API Key (starts with sk-prismer-) or IM JWT token */
169
- apiKey: string;
168
+ /** API Key (starts with sk-prismer-) or IM JWT token. Optional for anonymous IM registration. */
169
+ apiKey?: string;
170
170
  /** Environment preset (default: 'production'). Sets the base URL automatically. */
171
171
  environment?: Environment;
172
172
  /** Base URL override. Takes priority over `environment` if both are set. */
@@ -716,14 +716,19 @@ declare class IMClient {
716
716
  health(): Promise<IMResult<void>>;
717
717
  }
718
718
  declare class PrismerClient {
719
- private readonly apiKey;
719
+ private apiKey;
720
720
  private readonly baseUrl;
721
721
  private readonly timeout;
722
722
  private readonly fetchFn;
723
723
  private readonly imAgent?;
724
724
  /** IM API sub-client */
725
725
  readonly im: IMClient;
726
- constructor(config: PrismerConfig);
726
+ constructor(config?: PrismerConfig);
727
+ /**
728
+ * Set or update the auth token (API key or IM JWT).
729
+ * Useful after anonymous registration to set the returned JWT.
730
+ */
731
+ setToken(token: string): void;
727
732
  private _request;
728
733
  /** Load content from URL(s) or search query */
729
734
  load(input: string | string[], options?: LoadOptions): Promise<LoadResult>;
package/dist/index.js CHANGED
@@ -727,14 +727,11 @@ var IMClient = class {
727
727
  }
728
728
  };
729
729
  var PrismerClient = class {
730
- constructor(config) {
731
- if (!config.apiKey) {
732
- throw new Error("apiKey is required");
733
- }
734
- if (!config.apiKey.startsWith("sk-prismer-") && !config.apiKey.startsWith("eyJ")) {
730
+ constructor(config = {}) {
731
+ if (config.apiKey && !config.apiKey.startsWith("sk-prismer-") && !config.apiKey.startsWith("eyJ")) {
735
732
  console.warn('Warning: API key should start with "sk-prismer-" (or "eyJ" for IM JWT)');
736
733
  }
737
- this.apiKey = config.apiKey;
734
+ this.apiKey = config.apiKey || "";
738
735
  const envUrl = ENVIRONMENTS[config.environment || "production"];
739
736
  this.baseUrl = (config.baseUrl || envUrl).replace(/\/$/, "");
740
737
  this.timeout = config.timeout || 3e4;
@@ -745,6 +742,13 @@ var PrismerClient = class {
745
742
  this.baseUrl
746
743
  );
747
744
  }
745
+ /**
746
+ * Set or update the auth token (API key or IM JWT).
747
+ * Useful after anonymous registration to set the returned JWT.
748
+ */
749
+ setToken(token) {
750
+ this.apiKey = token;
751
+ }
748
752
  // --------------------------------------------------------------------------
749
753
  // Internal request helper
750
754
  // --------------------------------------------------------------------------
@@ -756,9 +760,10 @@ var PrismerClient = class {
756
760
  if (query && Object.keys(query).length > 0) {
757
761
  url += "?" + new URLSearchParams(query).toString();
758
762
  }
759
- const headers = {
760
- "Authorization": `Bearer ${this.apiKey}`
761
- };
763
+ const headers = {};
764
+ if (this.apiKey) {
765
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
766
+ }
762
767
  if (this.imAgent) {
763
768
  headers["X-IM-Agent"] = this.imAgent;
764
769
  }
package/dist/index.mjs CHANGED
@@ -685,14 +685,11 @@ var IMClient = class {
685
685
  }
686
686
  };
687
687
  var PrismerClient = class {
688
- constructor(config) {
689
- if (!config.apiKey) {
690
- throw new Error("apiKey is required");
691
- }
692
- if (!config.apiKey.startsWith("sk-prismer-") && !config.apiKey.startsWith("eyJ")) {
688
+ constructor(config = {}) {
689
+ if (config.apiKey && !config.apiKey.startsWith("sk-prismer-") && !config.apiKey.startsWith("eyJ")) {
693
690
  console.warn('Warning: API key should start with "sk-prismer-" (or "eyJ" for IM JWT)');
694
691
  }
695
- this.apiKey = config.apiKey;
692
+ this.apiKey = config.apiKey || "";
696
693
  const envUrl = ENVIRONMENTS[config.environment || "production"];
697
694
  this.baseUrl = (config.baseUrl || envUrl).replace(/\/$/, "");
698
695
  this.timeout = config.timeout || 3e4;
@@ -703,6 +700,13 @@ var PrismerClient = class {
703
700
  this.baseUrl
704
701
  );
705
702
  }
703
+ /**
704
+ * Set or update the auth token (API key or IM JWT).
705
+ * Useful after anonymous registration to set the returned JWT.
706
+ */
707
+ setToken(token) {
708
+ this.apiKey = token;
709
+ }
706
710
  // --------------------------------------------------------------------------
707
711
  // Internal request helper
708
712
  // --------------------------------------------------------------------------
@@ -714,9 +718,10 @@ var PrismerClient = class {
714
718
  if (query && Object.keys(query).length > 0) {
715
719
  url += "?" + new URLSearchParams(query).toString();
716
720
  }
717
- const headers = {
718
- "Authorization": `Bearer ${this.apiKey}`
719
- };
721
+ const headers = {};
722
+ if (this.apiKey) {
723
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
724
+ }
720
725
  if (this.imAgent) {
721
726
  headers["X-IM-Agent"] = this.imAgent;
722
727
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismer/sdk",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Official TypeScript SDK for Prismer Cloud API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",