@ziggs-ai/api-client 0.36.1 → 0.36.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.
|
@@ -327,12 +327,16 @@ export const openCapability = {
|
|
|
327
327
|
names: { sdk: 'open', mcp: 'ziggs_open' },
|
|
328
328
|
title: 'Open a returned resource',
|
|
329
329
|
descriptions: {
|
|
330
|
-
sdk: 'Read a returned resource: pass exactly one of artifactId, chatId, taskId, agreementId. The backend resolves access and returns scoped actions with required inputs and recovery calls. Opening executes none of those actions. Extraction pending/failed is not an empty document.',
|
|
330
|
+
sdk: 'Read a returned resource: pass exactly one of artifactId, chatId, taskId, agreementId. The backend resolves access and returns scoped actions with required inputs and recovery calls. Opening executes none of those actions. Extraction pending/failed is not an empty document. To read a chat\'s messages under one agreement, use context_read with type=messages, via=chat:<id> and agreementId.',
|
|
331
331
|
},
|
|
332
332
|
annotation: 'read-only',
|
|
333
|
+
// agreementId here is the agreement to open, one id among four
|
|
334
|
+
// (OPEN_ID_PARAMS). It used to carry context_read's filter wording, so an
|
|
335
|
+
// agent passed it beside chatId as a filter and was refused by the
|
|
336
|
+
// exactly-one rule. Filtering a room's messages to one agreement is
|
|
337
|
+
// context_read's job, and the description says so.
|
|
333
338
|
params: {
|
|
334
339
|
...OPEN_ID_PARAMS,
|
|
335
|
-
agreementId: { type: 'string', description: 'Filter message history to this exact work agreement. Use cursor pagination to expand a wake packet.' },
|
|
336
340
|
cursor: { type: 'string', description: 'Opaque cursor from a prior open page' },
|
|
337
341
|
after: { type: 'string', description: 'ISO timestamp for a forward-delta' },
|
|
338
342
|
limit: { type: 'number', description: 'Page size' },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { marketplaceFormation } from '../engagementGuide.js';
|
|
2
|
-
import {
|
|
2
|
+
import { pullOffersPage, pullRequests } from '../http/MarketplaceClient.js';
|
|
3
3
|
import { fullCreds } from './types.js';
|
|
4
4
|
import { nextCall } from './nextCall.js';
|
|
5
5
|
import { LIST_FIELDS_PARAM, parseListFields, pickListedRows } from './listedFields.js';
|
|
@@ -94,10 +94,13 @@ export const marketplaceViewCapability = {
|
|
|
94
94
|
limit: typeof args['limit'] === 'number' ? args['limit'] : 20,
|
|
95
95
|
...(args['since'] ? { since: args['since'] } : {}),
|
|
96
96
|
};
|
|
97
|
-
const [requests,
|
|
97
|
+
const [requests, offerPage] = await Promise.all([
|
|
98
98
|
kind === 'offers' ? Promise.resolve([]) : pullRequests(options, creds),
|
|
99
|
-
kind === 'requests'
|
|
99
|
+
kind === 'requests'
|
|
100
|
+
? Promise.resolve({ offers: [], total: null, hasMore: false })
|
|
101
|
+
: pullOffersPage(options, creds),
|
|
100
102
|
]);
|
|
103
|
+
const offers = offerPage.offers;
|
|
101
104
|
const fields = parseListFields(args['fields']);
|
|
102
105
|
const requestRows = pickListedRows(requests.map((q) => toListingRow(q, 'request')), fields);
|
|
103
106
|
const offerRows = pickListedRows(offers.map((o) => toListingRow(o, 'offer')), fields);
|
|
@@ -110,7 +113,20 @@ export const marketplaceViewCapability = {
|
|
|
110
113
|
? { requests: requestRows, requestCount: requests.length }
|
|
111
114
|
: {}),
|
|
112
115
|
...(kind !== 'requests'
|
|
113
|
-
? {
|
|
116
|
+
? {
|
|
117
|
+
offers: offerRows,
|
|
118
|
+
offerCount: offers.length,
|
|
119
|
+
// The board is capped: say so only when more exist, so the count
|
|
120
|
+
// above is never read as all of them.
|
|
121
|
+
...(offerPage.hasMore
|
|
122
|
+
? {
|
|
123
|
+
moreOffers: {
|
|
124
|
+
total: offerPage.total,
|
|
125
|
+
note: 'More listings exist than this read returned. Read again with a larger limit (at most 100) or narrow with since.',
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
: {}),
|
|
129
|
+
}
|
|
114
130
|
: {}),
|
|
115
131
|
engagement,
|
|
116
132
|
// Claiming is the move after browsing, and the id is in the row the
|
|
@@ -125,7 +125,7 @@ const BRIEFS = {
|
|
|
125
125
|
},
|
|
126
126
|
// Reading context
|
|
127
127
|
ziggs_open: {
|
|
128
|
-
does: 'Reads one artifact, chat, task or agreement by id, with the actions you may take and any recovery call. Hidden and unknown look the same.',
|
|
128
|
+
does: 'Reads one artifact, chat, task or agreement by id (exactly one id), with the actions you may take and any recovery call. Hidden and unknown look the same. A chat\'s messages under one agreement: ziggs_context_read with agreementId.',
|
|
129
129
|
},
|
|
130
130
|
ziggs_access_explain: {
|
|
131
131
|
does: 'Explains what you may do with one artifact, chat, task or agreement, and the recovery calls; runs none of them.',
|
|
@@ -47,6 +47,16 @@ export interface PullOffersOptions {
|
|
|
47
47
|
since?: string;
|
|
48
48
|
}
|
|
49
49
|
export declare function pullOffers(options: PullOffersOptions | undefined, creds: Creds): Promise<Agreement[]>;
|
|
50
|
+
/**
|
|
51
|
+
* The board read with its total. The board is capped (at most 100 rows), so
|
|
52
|
+
* the number of rows returned is not the number of listings. `total` and
|
|
53
|
+
* `hasMore` are absent from an older server; read them as unknown, not none.
|
|
54
|
+
*/
|
|
55
|
+
export declare function pullOffersPage(options: PullOffersOptions | undefined, creds: Creds): Promise<{
|
|
56
|
+
offers: Agreement[];
|
|
57
|
+
total: number | null;
|
|
58
|
+
hasMore: boolean;
|
|
59
|
+
}>;
|
|
50
60
|
export interface PullRequestsOptions {
|
|
51
61
|
limit?: number;
|
|
52
62
|
since?: string;
|
|
@@ -64,6 +64,14 @@ async function setOfferPaused(agreementId, verb, creds) {
|
|
|
64
64
|
return shapeAgreement(data['agreement']);
|
|
65
65
|
}
|
|
66
66
|
export async function pullOffers(options, creds) {
|
|
67
|
+
return (await pullOffersPage(options, creds)).offers;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The board read with its total. The board is capped (at most 100 rows), so
|
|
71
|
+
* the number of rows returned is not the number of listings. `total` and
|
|
72
|
+
* `hasMore` are absent from an older server; read them as unknown, not none.
|
|
73
|
+
*/
|
|
74
|
+
export async function pullOffersPage(options, creds) {
|
|
67
75
|
assertCreds(creds, 'marketplace offers pull');
|
|
68
76
|
const params = new URLSearchParams();
|
|
69
77
|
if (options?.limit != null)
|
|
@@ -80,7 +88,9 @@ export async function pullOffers(options, creds) {
|
|
|
80
88
|
throwApiError(res, body, `Marketplace offers pull failed: ${res.status}`);
|
|
81
89
|
}
|
|
82
90
|
const data = await res.json().catch(() => null);
|
|
83
|
-
|
|
91
|
+
const offers = data?.['offers'] ?? [];
|
|
92
|
+
const total = typeof data?.['total'] === 'number' ? data['total'] : null;
|
|
93
|
+
return { offers, total, hasMore: data?.['hasMore'] === true };
|
|
84
94
|
}
|
|
85
95
|
export async function pullRequests(options, creds) {
|
|
86
96
|
assertCreds(creds, 'request pull');
|