@neta-art/cohub 1.7.0 → 1.8.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.
@@ -0,0 +1,8 @@
1
+ import type { CreateGenerationRequest, Generation, ListGenerationDeclarationsResponse } from "@neta-art/cohub-protocol";
2
+ import type { HttpTransport } from "../transport.js";
3
+ export declare class GenerationsApi {
4
+ private readonly transport;
5
+ constructor(transport: HttpTransport);
6
+ create(request: CreateGenerationRequest): Promise<Generation>;
7
+ listDeclarations(): Promise<ListGenerationDeclarationsResponse>;
8
+ }
@@ -0,0 +1,16 @@
1
+ export class GenerationsApi {
2
+ transport;
3
+ constructor(transport) {
4
+ this.transport = transport;
5
+ }
6
+ async create(request) {
7
+ return this.transport.request("/api/generations", {
8
+ method: "POST",
9
+ headers: { "Content-Type": "application/json" },
10
+ body: JSON.stringify(request),
11
+ });
12
+ }
13
+ async listDeclarations() {
14
+ return this.transport.request("/api/generations/declarations");
15
+ }
16
+ }
@@ -0,0 +1,10 @@
1
+ import type { Fetch, HttpTransport } from "../transport.js";
2
+ import type { GlobalSearchResponse } from "../types.js";
3
+ export declare class SearchApi {
4
+ private readonly transport;
5
+ constructor(transport: HttpTransport);
6
+ query(input: {
7
+ q: string;
8
+ limit?: number;
9
+ }, customFetch?: Fetch): Promise<GlobalSearchResponse>;
10
+ }
@@ -0,0 +1,14 @@
1
+ export class SearchApi {
2
+ transport;
3
+ constructor(transport) {
4
+ this.transport = transport;
5
+ }
6
+ query(input, customFetch) {
7
+ const params = new URLSearchParams({ q: input.q });
8
+ if (input.limit !== undefined)
9
+ params.set("limit", String(input.limit));
10
+ return this.transport.request(`/api/search?${params.toString()}`, {
11
+ fetch: customFetch,
12
+ });
13
+ }
14
+ }
package/dist/client.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { ChannelsApi } from "./apis/channels.js";
2
2
  import { CronJobsApi } from "./apis/cron-jobs.js";
3
3
  import { ExploreApi } from "./apis/explore.js";
4
+ import { GenerationsApi } from "./apis/generations.js";
4
5
  import { ModelsApi } from "./apis/models.js";
5
6
  import { PromptsApi } from "./apis/prompts.js";
6
7
  import { SessionAccessApi } from "./apis/session-access.js";
8
+ import { SearchApi } from "./apis/search.js";
7
9
  import { SpaceClient, SpacesApi, type WebSocketConnectionState } from "./apis/spaces.js";
8
10
  import { TasksApi } from "./apis/tasks.js";
9
11
  import { UserApi } from "./apis/user.js";
@@ -13,9 +15,11 @@ export declare class CohubClient {
13
15
  readonly spaces: SpacesApi;
14
16
  readonly channels: ChannelsApi;
15
17
  readonly user: UserApi;
18
+ readonly generations: GenerationsApi;
16
19
  readonly models: ModelsApi;
17
20
  readonly prompts: PromptsApi;
18
21
  readonly sessionAccess: SessionAccessApi;
22
+ readonly search: SearchApi;
19
23
  readonly tasks: TasksApi;
20
24
  readonly cronJobs: CronJobsApi;
21
25
  readonly explore: ExploreApi;
package/dist/client.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { ChannelsApi } from "./apis/channels.js";
2
2
  import { CronJobsApi } from "./apis/cron-jobs.js";
3
3
  import { ExploreApi } from "./apis/explore.js";
4
+ import { GenerationsApi } from "./apis/generations.js";
4
5
  import { ModelsApi } from "./apis/models.js";
5
6
  import { PromptsApi } from "./apis/prompts.js";
6
7
  import { SessionAccessApi } from "./apis/session-access.js";
8
+ import { SearchApi } from "./apis/search.js";
7
9
  import { SpaceClient, SpacesApi } from "./apis/spaces.js";
8
10
  import { TasksApi } from "./apis/tasks.js";
9
11
  import { UserApi } from "./apis/user.js";
@@ -15,9 +17,11 @@ export class CohubClient {
15
17
  spaces;
16
18
  channels;
17
19
  user;
20
+ generations;
18
21
  models;
19
22
  prompts;
20
23
  sessionAccess;
24
+ search;
21
25
  tasks;
22
26
  cronJobs;
23
27
  explore;
@@ -38,9 +42,11 @@ export class CohubClient {
38
42
  this.spaces = new SpacesApi(this.transport);
39
43
  this.channels = new ChannelsApi(this.transport);
40
44
  this.user = new UserApi(this.transport, apiBaseUrl, options.setStoredAuthToken, options.clearStoredAuthToken);
45
+ this.generations = new GenerationsApi(this.transport);
41
46
  this.models = new ModelsApi(this.transport);
42
47
  this.prompts = new PromptsApi(this.transport);
43
48
  this.sessionAccess = new SessionAccessApi(this.transport);
49
+ this.search = new SearchApi(this.transport);
44
50
  this.tasks = new TasksApi(this.transport);
45
51
  this.cronJobs = new CronJobsApi(this.transport);
46
52
  this.explore = new ExploreApi(this.transport);
package/dist/http.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ChannelsApi } from "./apis/channels.js";
2
2
  import { CronJobsApi } from "./apis/cron-jobs.js";
3
+ import { GenerationsApi } from "./apis/generations.js";
3
4
  import { ModelsApi } from "./apis/models.js";
4
5
  import { PromptsApi } from "./apis/prompts.js";
5
6
  import { SessionAccessApi } from "./apis/session-access.js";
@@ -12,6 +13,7 @@ export declare class CohubHttpClient {
12
13
  readonly spaces: SpacesApi;
13
14
  readonly channels: ChannelsApi;
14
15
  readonly user: UserApi;
16
+ readonly generations: GenerationsApi;
15
17
  readonly models: ModelsApi;
16
18
  readonly prompts: PromptsApi;
17
19
  readonly sessionAccess: SessionAccessApi;
package/dist/http.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ChannelsApi } from "./apis/channels.js";
2
2
  import { CronJobsApi } from "./apis/cron-jobs.js";
3
+ import { GenerationsApi } from "./apis/generations.js";
3
4
  import { ModelsApi } from "./apis/models.js";
4
5
  import { PromptsApi } from "./apis/prompts.js";
5
6
  import { SessionAccessApi } from "./apis/session-access.js";
@@ -13,6 +14,7 @@ export class CohubHttpClient {
13
14
  spaces;
14
15
  channels;
15
16
  user;
17
+ generations;
16
18
  models;
17
19
  prompts;
18
20
  sessionAccess;
@@ -26,6 +28,7 @@ export class CohubHttpClient {
26
28
  this.spaces = new SpacesApi(this.transport);
27
29
  this.channels = new ChannelsApi(this.transport);
28
30
  this.user = new UserApi(this.transport, apiBaseUrl, options.setStoredAuthToken, options.clearStoredAuthToken);
31
+ this.generations = new GenerationsApi(this.transport);
29
32
  this.models = new ModelsApi(this.transport);
30
33
  this.prompts = new PromptsApi(this.transport);
31
34
  this.sessionAccess = new SessionAccessApi(this.transport);
@@ -167,11 +167,12 @@ export class SessionGenerationStreamClient {
167
167
  throw new Error("realtime transport is not configured for this client");
168
168
  }
169
169
  ensureRealtimeConnected(this.websocketClient);
170
+ const stream = new SessionGenerationStreamClient(this.websocketClient, this.spaceId, this.sessionId);
170
171
  const unsubscribe = this.websocketClient.on("event", (event) => {
171
172
  if (event.spaceId !== this.spaceId || event.sessionId !== this.sessionId) {
172
173
  return;
173
174
  }
174
- this.handleEvent(event, handlers);
175
+ stream.handleEvent(event, handlers);
175
176
  });
176
177
  return () => unsubscribe();
177
178
  }
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { SessionBindingRecord as ProtocolSessionBindingRecord, SessionRecord as ProtocolSessionRecord, SessionForkRecord, SessionTurnIndexItem, SessionTurnRecord, SessionTurnSegmentRecord } from "@neta-art/cohub-protocol/model";
2
2
  import type { ChannelConfig } from "@neta-art/cohub-protocol/gateway";
3
3
  import type { ContentBlock, Usage } from "@neta-art/cohub-protocol/core";
4
+ import type { Generation, ListGenerationDeclarationsResponse, PublicGenerationDeclaration, CreateGenerationRequest } from "@neta-art/cohub-protocol";
4
5
  import type { MessageRecord } from "@neta-art/cohub-protocol/model";
5
6
  export type { ChannelConfig, DiscordChannelConfig, } from "@neta-art/cohub-protocol/gateway";
6
7
  export type ApiError = {
@@ -24,7 +25,7 @@ export type UserRulesResponse = {
24
25
  source: "config-space";
25
26
  path: string;
26
27
  };
27
- export type { ContentBlock, MessageRecord, SessionTurnRecord, SessionTurnIndexItem, SessionForkRecord, SessionTurnSegmentRecord };
28
+ export type { ContentBlock, MessageRecord, SessionTurnRecord, SessionTurnIndexItem, SessionForkRecord, SessionTurnSegmentRecord, Generation, ListGenerationDeclarationsResponse, PublicGenerationDeclaration, CreateGenerationRequest, };
28
29
  export type SpaceFsEntry = {
29
30
  name: string;
30
31
  path: string;
@@ -279,6 +280,32 @@ export type SpaceChannelBindingInput = {
279
280
  channelId: string;
280
281
  config?: ChannelConfig | null;
281
282
  };
283
+ export type GlobalSearchResult = {
284
+ type: "turn" | "session" | "space";
285
+ id: string;
286
+ spaceId: string;
287
+ sessionId: string | null;
288
+ turnId: string | null;
289
+ sequence: number | null;
290
+ title: string;
291
+ excerpt: string | null;
292
+ spaceName: string | null;
293
+ sessionTitle: string | null;
294
+ matchedField: "userText" | "title" | "name" | "description";
295
+ href: string;
296
+ score: number;
297
+ textScore: number;
298
+ recencyScore: number;
299
+ typePriorityScore: number;
300
+ updatedAt: string | null;
301
+ source: "remote";
302
+ };
303
+ export type GlobalSearchResponse = {
304
+ items: GlobalSearchResult[];
305
+ query: string;
306
+ source: "remote";
307
+ degraded?: boolean;
308
+ };
282
309
  export type SpaceSessionsResponse = {
283
310
  sessions: SessionRecord[];
284
311
  pageInfo?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Cohub SDK for spaces, sessions, checkpoints, and realtime agent collaboration.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -44,7 +44,7 @@
44
44
  "README.md"
45
45
  ],
46
46
  "dependencies": {
47
- "@neta-art/cohub-protocol": "1.5.0"
47
+ "@neta-art/cohub-protocol": "1.6.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "typescript": "^6.0.3"