@pingagent/sdk 0.1.1 → 0.1.3

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/dist/index.d.ts CHANGED
@@ -151,6 +151,8 @@ interface ConversationEntry {
151
151
  target_did: string;
152
152
  trusted: boolean;
153
153
  created_at: number;
154
+ /** Server-side last message write time (ms). Omitted or null when unknown; client should fetch when missing. */
155
+ last_activity_at?: number | null;
154
156
  }
155
157
  interface ConversationListResponse {
156
158
  conversations: ConversationEntry[];
@@ -473,6 +475,8 @@ interface WsSubscriptionOptions {
473
475
  onMessage: (envelope: any, conversationId: string) => void;
474
476
  onControl?: (control: WsControlPayload, conversationId: string) => void;
475
477
  onError?: (err: Error) => void;
478
+ /** Called when a WebSocket opens or reopens; e.g. Skill can run catchUp to fill gaps. */
479
+ onOpen?: (conversationId: string) => void;
476
480
  }
477
481
  declare class WsSubscription {
478
482
  private opts;
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  loadIdentity,
17
17
  saveIdentity,
18
18
  updateStoredToken
19
- } from "./chunk-4SRPVWK4.js";
19
+ } from "./chunk-HMVPT5N4.js";
20
20
  export {
21
21
  A2AAdapter,
22
22
  ContactManager,
@@ -5,7 +5,7 @@ import {
5
5
  ensureTokenValid,
6
6
  loadIdentity,
7
7
  updateStoredToken
8
- } from "./chunk-4SRPVWK4.js";
8
+ } from "./chunk-HMVPT5N4.js";
9
9
 
10
10
  // src/web-server.ts
11
11
  import * as fs from "fs";
@@ -75,7 +75,7 @@ function listProfiles(rootDir) {
75
75
  }
76
76
  return profiles;
77
77
  }
78
- var DEFAULT_SERVER_URL = "http://localhost:8787";
78
+ var DEFAULT_SERVER_URL = "https://pingagent.chat";
79
79
  async function getContextForProfile(profile, defaultServerUrl) {
80
80
  const identity = loadIdentity(profile.identityPath);
81
81
  const serverUrl = identity.serverUrl ?? defaultServerUrl ?? DEFAULT_SERVER_URL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingagent/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,8 +27,8 @@
27
27
  "uuid": "^11.0.0",
28
28
  "ws": "^8.0.0",
29
29
  "@pingagent/protocol": "0.1.1",
30
- "@pingagent/a2a": "0.1.1",
31
- "@pingagent/schemas": "0.1.1"
30
+ "@pingagent/schemas": "0.1.1",
31
+ "@pingagent/a2a": "0.1.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/better-sqlite3": "^7.6.0",
package/src/auth.ts CHANGED
@@ -26,7 +26,7 @@ export async function ensureTokenValid(
26
26
  const now = Date.now();
27
27
  if (expiresAt > now + REFRESH_GRACE_MS) return false; // still valid, no need to refresh
28
28
 
29
- const baseUrl = (serverUrl ?? id.serverUrl ?? 'http://localhost:8787').replace(/\/$/, '');
29
+ const baseUrl = (serverUrl ?? id.serverUrl ?? 'https://pingagent.chat').replace(/\/$/, '');
30
30
  try {
31
31
  const res = await fetch(`${baseUrl}/v1/auth/refresh`, {
32
32
  method: 'POST',
package/src/client.ts CHANGED
@@ -62,6 +62,8 @@ export interface ConversationEntry {
62
62
  target_did: string;
63
63
  trusted: boolean;
64
64
  created_at: number;
65
+ /** Server-side last message write time (ms). Omitted or null when unknown; client should fetch when missing. */
66
+ last_activity_at?: number | null;
65
67
  }
66
68
 
67
69
  export interface ConversationListResponse {
package/src/web-server.ts CHANGED
@@ -110,7 +110,7 @@ function listProfiles(rootDir: string): ProfileEntry[] {
110
110
  }
111
111
 
112
112
  /** Default server URL when identity has none (e.g. legacy). */
113
- const DEFAULT_SERVER_URL = 'http://localhost:8787';
113
+ const DEFAULT_SERVER_URL = 'https://pingagent.chat';
114
114
 
115
115
  async function getContextForProfile(
116
116
  profile: ProfileEntry,
@@ -19,6 +19,8 @@ export interface WsSubscriptionOptions {
19
19
  onMessage: (envelope: any, conversationId: string) => void;
20
20
  onControl?: (control: WsControlPayload, conversationId: string) => void;
21
21
  onError?: (err: Error) => void;
22
+ /** Called when a WebSocket opens or reopens; e.g. Skill can run catchUp to fill gaps. */
23
+ onOpen?: (conversationId: string) => void;
22
24
  }
23
25
 
24
26
  const RECONNECT_BASE_MS = 1000;
@@ -106,6 +108,7 @@ export class WsSubscription {
106
108
 
107
109
  ws.on('open', () => {
108
110
  this.reconnectAttempts.set(conversationId, 0);
111
+ this.opts.onOpen?.(conversationId);
109
112
  // ws_connected will arrive as first message
110
113
  });
111
114