@neta-art/cohub 2.11.1 → 2.12.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/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Cohub
2
+ Copyright 2026 Viscept Limited
3
+
4
+ This product includes software developed by Viscept Limited and contributors.
@@ -293,6 +293,8 @@ declare const createWorkRuntime: (transport?: WorkRuntimeTransport, workId?: str
293
293
  type Fetch = typeof globalThis.fetch;
294
294
  type RequestInitWithFetch = RequestInit & {
295
295
  fetch?: Fetch;
296
+ /** When true, 401 responses throw without invoking onUnauthorized (e.g. session bootstrap). */
297
+ skipUnauthorizedHandler?: boolean;
296
298
  };
297
299
  type RawHttpResponse = {
298
300
  response: Response;
@@ -566,6 +568,7 @@ declare class ReferencesApi {
566
568
  groupBy?: ReferenceAggregateGroupBy;
567
569
  kinds?: ReferenceKind[];
568
570
  days?: number;
571
+ limit?: number;
569
572
  }, customFetch?: Fetch): Promise<ReferenceAggregateResponse>;
570
573
  }
571
574
  //#endregion
@@ -815,6 +818,11 @@ declare class SpacesApi {
815
818
  private readonly transport;
816
819
  constructor(transport: HttpTransport);
817
820
  list(customFetch?: Fetch): Promise<SpaceRecord[]>;
821
+ /**
822
+ * Resolve the user's default space (owned/member home, else most recent).
823
+ * When the account has no accessible space, the API creates a blank Home
824
+ * space (`slug=home`) and returns it.
825
+ */
818
826
  getDefault(customFetch?: Fetch): Promise<SpaceDefaultResponse>;
819
827
  get(spaceId: string, customFetch?: Fetch): Promise<SpaceRecord>;
820
828
  getBySlug(username: string, slug: string, customFetch?: Fetch): Promise<SpaceRecord>;
@@ -1420,7 +1428,10 @@ declare class UserApi {
1420
1428
  private readonly setStoredAuthToken?;
1421
1429
  private readonly clearStoredAuthToken?;
1422
1430
  constructor(transport: HttpTransport, transportBaseUrl: string, setStoredAuthToken?: ((token: string) => void) | undefined, clearStoredAuthToken?: (() => void) | undefined);
1423
- getMe(customFetch?: Fetch): Promise<MeResponse>;
1431
+ getMe(options?: Fetch | {
1432
+ fetch?: Fetch;
1433
+ skipUnauthorizedHandler?: boolean;
1434
+ }): Promise<MeResponse>;
1424
1435
  updateProfile(input: {
1425
1436
  displayName?: string;
1426
1437
  avatarUrl?: string | null;
@@ -311,6 +311,7 @@ var ReferencesApi = class {
311
311
  if (input.groupBy) params.set("groupBy", input.groupBy);
312
312
  if (input.kinds && input.kinds.length > 0) params.set("kinds", input.kinds.join(","));
313
313
  if (input.days !== void 0) params.set("days", String(input.days));
314
+ if (input.limit !== void 0) params.set("limit", String(input.limit));
314
315
  return this.transport.request(`/api/references/aggregate?${params.toString()}`, { fetch: customFetch });
315
316
  }
316
317
  };
@@ -1357,6 +1358,11 @@ var SpacesApi = class {
1357
1358
  fetch: customFetch
1358
1359
  });
1359
1360
  }
1361
+ /**
1362
+ * Resolve the user's default space (owned/member home, else most recent).
1363
+ * When the account has no accessible space, the API creates a blank Home
1364
+ * space (`slug=home`) and returns it.
1365
+ */
1360
1366
  getDefault(customFetch) {
1361
1367
  return this.transport.request("/api/spaces/default", {
1362
1368
  method: "GET",
@@ -2564,8 +2570,9 @@ var UserApi = class {
2564
2570
  this.setStoredAuthToken = setStoredAuthToken;
2565
2571
  this.clearStoredAuthToken = clearStoredAuthToken;
2566
2572
  }
2567
- getMe(customFetch) {
2568
- return this.transport.request("/api/me", { fetch: customFetch });
2573
+ getMe(options) {
2574
+ const init = typeof options === "function" ? { fetch: options } : options;
2575
+ return this.transport.request("/api/me", init);
2569
2576
  }
2570
2577
  updateProfile(input) {
2571
2578
  return this.transport.request("/api/me/profile", {
@@ -102,18 +102,20 @@ var HttpTransport = class {
102
102
  this.onUnauthorized = options.onUnauthorized;
103
103
  }
104
104
  async withAuthorization(init, tokenOverride) {
105
- const headers = new Headers(init?.headers);
105
+ const { fetch: _fetch, skipUnauthorizedHandler: _skip, ...requestInit } = init ?? {};
106
+ const headers = new Headers(requestInit.headers);
106
107
  const token = sanitizeAccessToken(tokenOverride !== void 0 ? tokenOverride : this.getAccessToken ? await this.getAccessToken() : null);
107
108
  if (token) headers.set("Authorization", `Bearer ${token}`);
108
109
  else headers.delete("Authorization");
109
110
  return {
110
- ...init,
111
+ ...requestInit,
111
112
  headers
112
113
  };
113
114
  }
114
115
  async send(path, init) {
115
116
  const fetcher = init?.fetch ?? this.fetcher;
116
117
  const url = joinApiUrl(this.baseUrl, path);
118
+ const skipUnauthorizedHandler = Boolean(init?.skipUnauthorizedHandler);
117
119
  let response;
118
120
  try {
119
121
  response = await fetcher(url, await this.withAuthorization(init));
@@ -148,7 +150,7 @@ var HttpTransport = class {
148
150
  }
149
151
  }
150
152
  if (response.status === 401) {
151
- await this.onUnauthorized?.();
153
+ if (!skipUnauthorizedHandler) await this.onUnauthorized?.();
152
154
  throw new HttpError("unauthorized", 401, null);
153
155
  }
154
156
  if (!response.ok) {
@@ -2205,7 +2205,7 @@ type ExploreSpacesResponse = {
2205
2205
  sections: ExploreSection[];
2206
2206
  spaces: ExploreSpaceItem[];
2207
2207
  };
2208
- type Permission = "space.view" | "space.edit" | "space.label.view" | "space.label.manage" | "space.label.assign" | "session.view" | "session.edit" | "session.prompt.readonly" | "session.prompt.fullaccess" | "generation.create" | "file.view" | "file.view.filtered" | "file.edit" | "checkpoint.view" | "checkpoint.edit" | "member.view" | "member.manage" | "channel.view" | "channel.manage" | "cronjob.view" | "cronjob.manage" | "taskrun.view" | "sandbox.view" | "sandbox.manage" | "mod.view" | "mod.manage" | "user.space.list" | "user.session.list" | "user.usage.read";
2208
+ type Permission = "space.view" | "space.edit" | "space.label.view" | "space.label.manage" | "space.label.assign" | "session.view" | "session.edit" | "session.prompt.readonly" | "session.prompt.fullaccess" | "generation.create" | "file.view" | "file.view.filtered" | "file.edit" | "checkpoint.view" | "checkpoint.edit" | "member.view" | "member.manage" | "references.view" | "channel.view" | "channel.manage" | "cronjob.view" | "cronjob.manage" | "taskrun.view" | "sandbox.view" | "sandbox.manage" | "mod.view" | "mod.manage" | "user.space.list" | "user.session.list" | "user.usage.read";
2209
2209
  type SpaceAccess = {
2210
2210
  role: SpaceRole | null;
2211
2211
  permissions: Permission[];
@@ -2339,23 +2339,23 @@ type AcceptInvitationResponse = {
2339
2339
  spaceName: string;
2340
2340
  role: SpaceRole;
2341
2341
  };
2342
- type ReferenceResourceType = "space" | "session" | "checkpoint" | "user" | "file" | "tool";
2342
+ type ReferenceResourceType = "turn" | "session" | "space" | "checkpoint" | "file";
2343
2343
  /**
2344
- * Resource types usable as a query `source`. Only these have an owning space to
2345
- * authorize against; user/file/tool appear only as reference targets.
2344
+ * Resource types usable as a query `source`: they resolve to an owning space to
2345
+ * authorize against. `turn` gives the finest precision; session/space roll up.
2346
+ * `file` appears only as an edge target, never as a queryable source.
2346
2347
  */
2347
- type ReferenceQueryableType = "space" | "session" | "checkpoint";
2348
- type ReferenceKind = "session_fork" | "space_fork" | "checkpoint_fork" | "mention" | "tool_call" | "mod" | "participant";
2348
+ type ReferenceQueryableType = "turn" | "session" | "space" | "checkpoint";
2349
+ type ReferenceKind = "session_fork" | "space_fork" | "checkpoint_fork" | "mod" | "mention" | "tool_call" | "agent_tool_file_read" | "agent_tool_file_write" | "agent_tool_file_edit" | "agent_tool_file_ls" | "agent_tool_file_find" | "agent_tool_file_grep";
2349
2350
  type ReferenceDirection = "out" | "in" | "both";
2350
2351
  type ReferenceRecord = {
2351
2352
  kind: ReferenceKind;
2352
2353
  sourceType: ReferenceResourceType;
2353
2354
  sourceId: string;
2354
- sourceTurnId: string | null;
2355
2355
  targetType: ReferenceResourceType;
2356
2356
  targetId: string;
2357
- spaceId: string;
2358
- sessionId: string | null;
2357
+ sourceSpaceId: string;
2358
+ sourceSessionId: string | null;
2359
2359
  count: number;
2360
2360
  createdAt: string;
2361
2361
  updatedAt: string;
@@ -2366,7 +2366,7 @@ type ReferenceQueryResponse = {
2366
2366
  direction: ReferenceDirection;
2367
2367
  references: ReferenceRecord[];
2368
2368
  };
2369
- type ReferenceAggregateGroupBy = "kind" | "targetType" | "sourceType" | "day";
2369
+ type ReferenceAggregateGroupBy = "kind" | "targetType" | "target" | "sourceType" | "day";
2370
2370
  type ReferenceAggregateGroup = {
2371
2371
  group: string;
2372
2372
  references: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub",
3
- "version": "2.11.1",
3
+ "version": "2.12.0",
4
4
  "description": "Cohub SDK for spaces, sessions, checkpoints, and realtime agent collaboration.",
5
5
  "license": "Apache-2.0",
6
6
  "private": false,
@@ -50,7 +50,9 @@
50
50
  "files": [
51
51
  "dist",
52
52
  "README.md",
53
- "docs"
53
+ "docs",
54
+ "LICENSE",
55
+ "NOTICE"
54
56
  ],
55
57
  "devDependencies": {
56
58
  "tsdown": "^0.22.7",