@ziggs-ai/api-client 0.1.13 → 0.1.15
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.
|
@@ -18,8 +18,9 @@ export interface WriteArtifactInput {
|
|
|
18
18
|
visibility?: ArtifactVisibility;
|
|
19
19
|
/** When the artifact is associated with a chat. */
|
|
20
20
|
chatId?: string;
|
|
21
|
-
/** When the artifact is associated with an agreement
|
|
21
|
+
/** When the artifact is associated with an agreement. */
|
|
22
22
|
agreementId?: string;
|
|
23
|
+
/** Optional task binding — creates a TaskArtifactLink alongside the primary scope link. */
|
|
23
24
|
taskId?: string;
|
|
24
25
|
service?: Record<string, unknown>;
|
|
25
26
|
}
|
|
@@ -13,7 +13,12 @@ export declare function openConversation(participantId: string, creds: Creds): P
|
|
|
13
13
|
}>;
|
|
14
14
|
export interface SendChatMessageInput {
|
|
15
15
|
chatId: string;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Recipient id. Optional (ZIG-548): when omitted, the backend infers the
|
|
18
|
+
* receiver if the chat has exactly one other member (one agent, or one
|
|
19
|
+
* other human). Provide it explicitly in chats with multiple members.
|
|
20
|
+
*/
|
|
21
|
+
receiverId?: string;
|
|
17
22
|
text: string;
|
|
18
23
|
messageId: string;
|
|
19
24
|
entryType?: string;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import 'dotenv/config';
|
|
2
2
|
export type InboxScopeKind = 'chat' | 'agreement' | 'org';
|
|
3
|
+
/**
|
|
4
|
+
* ZIG-543: which chats a multi-chat scope's news is in. Lets a scope-granted
|
|
5
|
+
* agent open the conversations behind the count (e.g. GET /chats/:chatId/messages).
|
|
6
|
+
*/
|
|
7
|
+
export interface InboxScopeChat {
|
|
8
|
+
chatId: string;
|
|
9
|
+
newMessages: number;
|
|
10
|
+
newArtifacts: number;
|
|
11
|
+
latestAt: string | null;
|
|
12
|
+
}
|
|
3
13
|
export interface InboxScopeEntry {
|
|
4
14
|
scope: {
|
|
5
15
|
kind: InboxScopeKind;
|
|
@@ -9,6 +19,10 @@ export interface InboxScopeEntry {
|
|
|
9
19
|
newArtifacts: number;
|
|
10
20
|
latestAt: string | null;
|
|
11
21
|
since: string;
|
|
22
|
+
/** Per-chat breakdown for org / agreement scopes (ZIG-543). Absent for a chat scope. */
|
|
23
|
+
chats?: InboxScopeChat[];
|
|
24
|
+
/** Chats with news beyond the per-scope cap, not listed in `chats`. */
|
|
25
|
+
truncatedChats?: number;
|
|
12
26
|
}
|
|
13
27
|
export interface InboxProposalRef {
|
|
14
28
|
agreementId: string;
|
|
@@ -46,6 +46,17 @@ export declare function claimLedgerTask(agreementId: string, creds: Creds, optio
|
|
|
46
46
|
}): Promise<Agreement>;
|
|
47
47
|
export declare function reportTask(taskId: string, message: string | undefined, creds: Creds): Promise<Task>;
|
|
48
48
|
export declare function setTaskSatisfaction(taskId: string, satisfaction: 'positive' | 'negative', creds: Creds): Promise<Task>;
|
|
49
|
+
export interface ListTasksOptions {
|
|
50
|
+
state?: string;
|
|
51
|
+
cursor?: string;
|
|
52
|
+
limit?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface ListTasksResult {
|
|
55
|
+
tasks: Task[];
|
|
56
|
+
hasMore: boolean;
|
|
57
|
+
nextCursor?: string | null;
|
|
58
|
+
}
|
|
59
|
+
export declare function listTasks(options: ListTasksOptions | undefined, creds: Creds): Promise<ListTasksResult>;
|
|
49
60
|
export interface CountTasksFilters {
|
|
50
61
|
chatId?: string;
|
|
51
62
|
state?: string;
|
|
@@ -71,5 +82,6 @@ export declare class TaskClient {
|
|
|
71
82
|
}): Promise<Agreement>;
|
|
72
83
|
reportTask(taskId: string, message?: string): Promise<Task>;
|
|
73
84
|
setTaskSatisfaction(taskId: string, satisfaction: 'positive' | 'negative'): Promise<Task>;
|
|
85
|
+
listTasks(options?: ListTasksOptions): Promise<ListTasksResult>;
|
|
74
86
|
countTasks(filters?: CountTasksFilters): Promise<number>;
|
|
75
87
|
}
|
package/dist/http/TaskClient.js
CHANGED
|
@@ -305,6 +305,31 @@ export async function setTaskSatisfaction(taskId, satisfaction, creds) {
|
|
|
305
305
|
throw new Error('Invalid response: task data not found');
|
|
306
306
|
return task;
|
|
307
307
|
}
|
|
308
|
+
export async function listTasks(options = {}, creds) {
|
|
309
|
+
assertCreds(creds, 'list tasks');
|
|
310
|
+
const url = new URL(getTaskBaseUrl());
|
|
311
|
+
if (options.state)
|
|
312
|
+
url.searchParams.set('state', options.state);
|
|
313
|
+
if (options.cursor)
|
|
314
|
+
url.searchParams.set('cursor', options.cursor);
|
|
315
|
+
if (options.limit != null)
|
|
316
|
+
url.searchParams.set('limit', String(options.limit));
|
|
317
|
+
const res = await fetch(url.toString(), {
|
|
318
|
+
method: 'GET',
|
|
319
|
+
headers: buildHeaders(creds),
|
|
320
|
+
});
|
|
321
|
+
if (!res.ok) {
|
|
322
|
+
const body = await res.text().catch(() => '');
|
|
323
|
+
throwApiError(res, body, `List tasks failed: ${res.status} ${res.statusText}`);
|
|
324
|
+
}
|
|
325
|
+
const data = await res.json().catch(() => null);
|
|
326
|
+
const tasks = Array.isArray(data?.['tasks']) ? data['tasks'] : [];
|
|
327
|
+
return {
|
|
328
|
+
tasks,
|
|
329
|
+
hasMore: Boolean(data?.['hasMore']),
|
|
330
|
+
nextCursor: data?.['nextCursor'] ?? null,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
308
333
|
export async function countTasks(filters = {}, creds) {
|
|
309
334
|
assertCreds(creds, 'count tasks');
|
|
310
335
|
// Canonical REST: GET /tasks/count.
|
|
@@ -353,5 +378,6 @@ export class TaskClient {
|
|
|
353
378
|
claimLedgerTask(taskId, options) { return claimLedgerTask(taskId, this.creds, options); }
|
|
354
379
|
reportTask(taskId, message) { return reportTask(taskId, message, this.creds); }
|
|
355
380
|
setTaskSatisfaction(taskId, satisfaction) { return setTaskSatisfaction(taskId, satisfaction, this.creds); }
|
|
381
|
+
listTasks(options) { return listTasks(options ?? {}, this.creds); }
|
|
356
382
|
countTasks(filters) { return countTasks(filters, this.creds); }
|
|
357
383
|
}
|