@acontext/acontext 0.0.6 → 0.0.8

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.
@@ -4,7 +4,7 @@
4
4
  import { RequesterProtocol } from '../client-types';
5
5
  import { AcontextMessage } from '../messages';
6
6
  import { FileUpload } from '../uploads';
7
- import { GetMessagesOutput, GetTasksOutput, LearningStatus, ListSessionsOutput, Message, Session } from '../types';
7
+ import { GetMessagesOutput, GetTasksOutput, LearningStatus, ListSessionsOutput, Message, Session, TokenCounts } from '../types';
8
8
  export type MessageBlob = AcontextMessage | Record<string, unknown>;
9
9
  export declare class SessionsAPI {
10
10
  private requester;
@@ -59,4 +59,11 @@ export declare class SessionsAPI {
59
59
  * @returns LearningStatus object containing space_digested_count and not_space_digested_count.
60
60
  */
61
61
  getLearningStatus(sessionId: string): Promise<LearningStatus>;
62
+ /**
63
+ * Get total token counts for all text and tool-call parts in a session.
64
+ *
65
+ * @param sessionId - The UUID of the session.
66
+ * @returns TokenCounts object containing total_tokens.
67
+ */
68
+ getTokenCounts(sessionId: string): Promise<TokenCounts>;
62
69
  }
@@ -148,5 +148,15 @@ class SessionsAPI {
148
148
  const data = await this.requester.request('GET', `/session/${sessionId}/get_learning_status`);
149
149
  return types_1.LearningStatusSchema.parse(data);
150
150
  }
151
+ /**
152
+ * Get total token counts for all text and tool-call parts in a session.
153
+ *
154
+ * @param sessionId - The UUID of the session.
155
+ * @returns TokenCounts object containing total_tokens.
156
+ */
157
+ async getTokenCounts(sessionId) {
158
+ const data = await this.requester.request('GET', `/session/${sessionId}/token_counts`);
159
+ return types_1.TokenCountsSchema.parse(data);
160
+ }
151
161
  }
152
162
  exports.SessionsAPI = SessionsAPI;
@@ -2,7 +2,7 @@
2
2
  * Spaces endpoints.
3
3
  */
4
4
  import { RequesterProtocol } from '../client-types';
5
- import { ListSpacesOutput, SearchResultBlockItem, Space, SpaceSearchResult } from '../types';
5
+ import { ExperienceConfirmation, ListExperienceConfirmationsOutput, ListSpacesOutput, SearchResultBlockItem, Space, SpaceSearchResult } from '../types';
6
6
  export declare class SpacesAPI {
7
7
  private requester;
8
8
  constructor(requester: RequesterProtocol);
@@ -67,4 +67,30 @@ export declare class SpacesAPI {
67
67
  limit?: number | null;
68
68
  threshold?: number | null;
69
69
  }): Promise<SearchResultBlockItem[]>;
70
+ /**
71
+ * Get all unconfirmed experiences in a space with cursor-based pagination.
72
+ *
73
+ * @param spaceId - The UUID of the space
74
+ * @param options - Pagination options
75
+ * @returns ListExperienceConfirmationsOutput containing the list of experience confirmations and pagination information
76
+ */
77
+ getUnconfirmedExperiences(spaceId: string, options?: {
78
+ limit?: number | null;
79
+ cursor?: string | null;
80
+ timeDesc?: boolean | null;
81
+ }): Promise<ListExperienceConfirmationsOutput>;
82
+ /**
83
+ * Confirm an experience confirmation.
84
+ *
85
+ * If save is false, delete the row. If save is true, get the data first,
86
+ * then delete the row.
87
+ *
88
+ * @param spaceId - The UUID of the space
89
+ * @param experienceId - The UUID of the experience confirmation
90
+ * @param options - Confirmation options
91
+ * @returns ExperienceConfirmation object if save is true, null otherwise
92
+ */
93
+ confirmExperience(spaceId: string, experienceId: string, options: {
94
+ save: boolean;
95
+ }): Promise<ExperienceConfirmation | null>;
70
96
  }
@@ -104,5 +104,40 @@ class SpacesAPI {
104
104
  const data = await this.requester.request('GET', `/space/${spaceId}/semantic_grep`, { params: Object.keys(params).length > 0 ? params : undefined });
105
105
  return data.map((item) => types_1.SearchResultBlockItemSchema.parse(item));
106
106
  }
107
+ /**
108
+ * Get all unconfirmed experiences in a space with cursor-based pagination.
109
+ *
110
+ * @param spaceId - The UUID of the space
111
+ * @param options - Pagination options
112
+ * @returns ListExperienceConfirmationsOutput containing the list of experience confirmations and pagination information
113
+ */
114
+ async getUnconfirmedExperiences(spaceId, options) {
115
+ const params = (0, utils_1.buildParams)({
116
+ limit: options?.limit ?? null,
117
+ cursor: options?.cursor ?? null,
118
+ time_desc: options?.timeDesc ?? null,
119
+ });
120
+ const data = await this.requester.request('GET', `/space/${spaceId}/experience_confirmations`, { params: Object.keys(params).length > 0 ? params : undefined });
121
+ return types_1.ListExperienceConfirmationsOutputSchema.parse(data);
122
+ }
123
+ /**
124
+ * Confirm an experience confirmation.
125
+ *
126
+ * If save is false, delete the row. If save is true, get the data first,
127
+ * then delete the row.
128
+ *
129
+ * @param spaceId - The UUID of the space
130
+ * @param experienceId - The UUID of the experience confirmation
131
+ * @param options - Confirmation options
132
+ * @returns ExperienceConfirmation object if save is true, null otherwise
133
+ */
134
+ async confirmExperience(spaceId, experienceId, options) {
135
+ const payload = { save: options.save };
136
+ const data = await this.requester.request('PATCH', `/space/${spaceId}/experience_confirmations/${experienceId}`, { jsonData: payload });
137
+ if (data === null || data === undefined) {
138
+ return null;
139
+ }
140
+ return types_1.ExperienceConfirmationSchema.parse(data);
141
+ }
107
142
  }
108
143
  exports.SpacesAPI = SpacesAPI;
@@ -124,3 +124,7 @@ export declare const LearningStatusSchema: z.ZodObject<{
124
124
  not_space_digested_count: z.ZodNumber;
125
125
  }, z.core.$strip>;
126
126
  export type LearningStatus = z.infer<typeof LearningStatusSchema>;
127
+ export declare const TokenCountsSchema: z.ZodObject<{
128
+ total_tokens: z.ZodNumber;
129
+ }, z.core.$strip>;
130
+ export type TokenCounts = z.infer<typeof TokenCountsSchema>;
@@ -3,7 +3,7 @@
3
3
  * Type definitions for session, message, and task resources.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LearningStatusSchema = exports.GetTasksOutputSchema = exports.GetMessagesOutputSchema = exports.PublicURLSchema = exports.ListSessionsOutputSchema = exports.TaskSchema = exports.SessionSchema = exports.MessageSchema = exports.PartSchema = exports.AssetSchema = void 0;
6
+ exports.TokenCountsSchema = exports.LearningStatusSchema = exports.GetTasksOutputSchema = exports.GetMessagesOutputSchema = exports.PublicURLSchema = exports.ListSessionsOutputSchema = exports.TaskSchema = exports.SessionSchema = exports.MessageSchema = exports.PartSchema = exports.AssetSchema = void 0;
7
7
  const zod_1 = require("zod");
8
8
  exports.AssetSchema = zod_1.z.object({
9
9
  bucket: zod_1.z.string(),
@@ -76,3 +76,6 @@ exports.LearningStatusSchema = zod_1.z.object({
76
76
  space_digested_count: zod_1.z.number(),
77
77
  not_space_digested_count: zod_1.z.number(),
78
78
  });
79
+ exports.TokenCountsSchema = zod_1.z.object({
80
+ total_tokens: zod_1.z.number(),
81
+ });
@@ -41,3 +41,25 @@ export declare const SpaceSearchResultSchema: z.ZodObject<{
41
41
  final_answer: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
42
  }, z.core.$strip>;
43
43
  export type SpaceSearchResult = z.infer<typeof SpaceSearchResultSchema>;
44
+ export declare const ExperienceConfirmationSchema: z.ZodObject<{
45
+ id: z.ZodString;
46
+ space_id: z.ZodString;
47
+ task_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ experience_data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
49
+ created_at: z.ZodString;
50
+ updated_at: z.ZodString;
51
+ }, z.core.$strip>;
52
+ export type ExperienceConfirmation = z.infer<typeof ExperienceConfirmationSchema>;
53
+ export declare const ListExperienceConfirmationsOutputSchema: z.ZodObject<{
54
+ items: z.ZodArray<z.ZodObject<{
55
+ id: z.ZodString;
56
+ space_id: z.ZodString;
57
+ task_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
+ experience_data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
59
+ created_at: z.ZodString;
60
+ updated_at: z.ZodString;
61
+ }, z.core.$strip>>;
62
+ next_cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
63
+ has_more: z.ZodBoolean;
64
+ }, z.core.$strip>;
65
+ export type ListExperienceConfirmationsOutput = z.infer<typeof ListExperienceConfirmationsOutputSchema>;
@@ -3,7 +3,7 @@
3
3
  * Type definitions for space resources.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SpaceSearchResultSchema = exports.SearchResultBlockItemSchema = exports.ListSpacesOutputSchema = exports.SpaceSchema = void 0;
6
+ exports.ListExperienceConfirmationsOutputSchema = exports.ExperienceConfirmationSchema = exports.SpaceSearchResultSchema = exports.SearchResultBlockItemSchema = exports.ListSpacesOutputSchema = exports.SpaceSchema = void 0;
7
7
  const zod_1 = require("zod");
8
8
  exports.SpaceSchema = zod_1.z.object({
9
9
  id: zod_1.z.string(),
@@ -28,3 +28,16 @@ exports.SpaceSearchResultSchema = zod_1.z.object({
28
28
  cited_blocks: zod_1.z.array(exports.SearchResultBlockItemSchema),
29
29
  final_answer: zod_1.z.string().nullable().optional(),
30
30
  });
31
+ exports.ExperienceConfirmationSchema = zod_1.z.object({
32
+ id: zod_1.z.string(),
33
+ space_id: zod_1.z.string(),
34
+ task_id: zod_1.z.string().nullable().optional(),
35
+ experience_data: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
36
+ created_at: zod_1.z.string(),
37
+ updated_at: zod_1.z.string(),
38
+ });
39
+ exports.ListExperienceConfirmationsOutputSchema = zod_1.z.object({
40
+ items: zod_1.z.array(exports.ExperienceConfirmationSchema),
41
+ next_cursor: zod_1.z.string().nullable().optional(),
42
+ has_more: zod_1.z.boolean(),
43
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acontext/acontext",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "TypeScript SDK for the Acontext API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",