@ziggs-ai/api-client 0.36.2 → 0.36.4
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/dist/capabilities/context.d.ts +28 -0
- package/dist/capabilities/context.js +32 -2
- package/dist/capabilities/discovery.js +8 -1
- package/dist/capabilities/index.d.ts +1 -1
- package/dist/capabilities/index.js +1 -1
- package/dist/capabilities/mcpBriefs.js +1 -1
- package/dist/http/ContextOpenClient.js +3 -1
- package/dist/http/PaymentsClient.d.ts +0 -5
- package/dist/http/PaymentsClient.js +0 -6
- package/package.json +1 -1
|
@@ -20,6 +20,34 @@ export declare const contextReadCapability: CapabilityDefinition;
|
|
|
20
20
|
export declare const contextExpandReachCapability: CapabilityDefinition;
|
|
21
21
|
export declare const contextDiscoverGrantableCapability: CapabilityDefinition;
|
|
22
22
|
export declare const contextDelegateCapability: CapabilityDefinition;
|
|
23
|
+
/**
|
|
24
|
+
* One answer for "you cannot read this", whichever tool asked.
|
|
25
|
+
*
|
|
26
|
+
* A get that the server refuses (404 or 403) used to answer in its own words:
|
|
27
|
+
* agreement_get said "not found" for an agreement that exists and that the
|
|
28
|
+
* caller could ask for, and task_get said "not a party" for a task that does
|
|
29
|
+
* not exist. The server already judges this once, for open and access_explain:
|
|
30
|
+
* readable, unreadable with a request to make, or hidden (and hidden looks
|
|
31
|
+
* exactly like missing). A refused get asks that same judgement, so every tool
|
|
32
|
+
* gives the same outcome and the same recovery for the same case, and none
|
|
33
|
+
* reveals more than open already does.
|
|
34
|
+
*
|
|
35
|
+
* Null when the judgement says the caller may read it after all: the refusal
|
|
36
|
+
* was something else, and the caller reports its own error.
|
|
37
|
+
*/
|
|
38
|
+
export interface RefusedRead {
|
|
39
|
+
code: 'RESOURCE_HIDDEN' | 'RESOURCE_UNREADABLE';
|
|
40
|
+
outcome: 'hidden' | 'unreadable';
|
|
41
|
+
message: string;
|
|
42
|
+
ref: {
|
|
43
|
+
kind: string;
|
|
44
|
+
id: string;
|
|
45
|
+
};
|
|
46
|
+
actions?: unknown[];
|
|
47
|
+
}
|
|
48
|
+
export declare const RESOURCE_HIDDEN_MESSAGE = "Not found, or not available to you. The two look the same.";
|
|
49
|
+
export declare const RESOURCE_UNREADABLE_MESSAGE = "This exists and you cannot read it yet. actions has the request to make.";
|
|
50
|
+
export declare function explainRefusedRead(kind: 'agreement' | 'task' | 'chat' | 'artifact', id: string, env: CapabilityEnv): Promise<RefusedRead | null>;
|
|
23
51
|
export declare const openCapability: CapabilityDefinition;
|
|
24
52
|
export declare const accessExplainCapability: CapabilityDefinition;
|
|
25
53
|
export declare const contextRequestCapability: CapabilityDefinition;
|
|
@@ -322,17 +322,47 @@ function presentOpenResult(result, env) {
|
|
|
322
322
|
} : {}),
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
|
+
export const RESOURCE_HIDDEN_MESSAGE = 'Not found, or not available to you. The two look the same.';
|
|
326
|
+
export const RESOURCE_UNREADABLE_MESSAGE = 'This exists and you cannot read it yet. actions has the request to make.';
|
|
327
|
+
export async function explainRefusedRead(kind, id, env) {
|
|
328
|
+
const creds = fullCreds(env);
|
|
329
|
+
let presented;
|
|
330
|
+
try {
|
|
331
|
+
const client = new ContextOpenClient(creds.operatorKey, creds.agentId, env.baseUrl, creds.laneId);
|
|
332
|
+
presented = presentOpenResult(await client.explain({ [`${kind}Id`]: id }), env);
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
const outcome = presented['outcome'];
|
|
338
|
+
if (outcome !== 'hidden' && outcome !== 'unreadable')
|
|
339
|
+
return null;
|
|
340
|
+
const actions = Array.isArray(presented['actions']) ? presented['actions'] : [];
|
|
341
|
+
return outcome === 'hidden'
|
|
342
|
+
? { code: 'RESOURCE_HIDDEN', outcome, message: RESOURCE_HIDDEN_MESSAGE, ref: { kind, id } }
|
|
343
|
+
: {
|
|
344
|
+
code: 'RESOURCE_UNREADABLE',
|
|
345
|
+
outcome,
|
|
346
|
+
message: RESOURCE_UNREADABLE_MESSAGE,
|
|
347
|
+
ref: { kind, id },
|
|
348
|
+
...(actions.length ? { actions } : {}),
|
|
349
|
+
};
|
|
350
|
+
}
|
|
325
351
|
export const openCapability = {
|
|
326
352
|
key: 'open',
|
|
327
353
|
names: { sdk: 'open', mcp: 'ziggs_open' },
|
|
328
354
|
title: 'Open a returned resource',
|
|
329
355
|
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.',
|
|
356
|
+
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
357
|
},
|
|
332
358
|
annotation: 'read-only',
|
|
359
|
+
// agreementId here is the agreement to open, one id among four
|
|
360
|
+
// (OPEN_ID_PARAMS). It used to carry context_read's filter wording, so an
|
|
361
|
+
// agent passed it beside chatId as a filter and was refused by the
|
|
362
|
+
// exactly-one rule. Filtering a room's messages to one agreement is
|
|
363
|
+
// context_read's job, and the description says so.
|
|
333
364
|
params: {
|
|
334
365
|
...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
366
|
cursor: { type: 'string', description: 'Opaque cursor from a prior open page' },
|
|
337
367
|
after: { type: 'string', description: 'ISO timestamp for a forward-delta' },
|
|
338
368
|
limit: { type: 'number', description: 'Page size' },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AgentSearchClient } from '../http/AgentSearchClient.js';
|
|
2
|
+
import { RESOURCE_HIDDEN_MESSAGE } from './context.js';
|
|
2
3
|
import { fullCreds } from './types.js';
|
|
3
4
|
export const agentSearchCapability = {
|
|
4
5
|
key: 'agent_search',
|
|
@@ -83,7 +84,13 @@ export const agentGetCapability = {
|
|
|
83
84
|
const client = new AgentSearchClient(creds.operatorKey, creds.agentId);
|
|
84
85
|
const result = await client.getAgentById(args['agentId']);
|
|
85
86
|
if (!result.success) {
|
|
86
|
-
|
|
87
|
+
// A missing agent and one you may not see answer alike, in the words
|
|
88
|
+
// every read tool uses. There is nothing to request: an agent is reached
|
|
89
|
+
// through its listing or its person, not by access to its profile.
|
|
90
|
+
if (result.error === 'agent not found') {
|
|
91
|
+
throw Object.assign(new Error(RESOURCE_HIDDEN_MESSAGE), { code: 'RESOURCE_HIDDEN' });
|
|
92
|
+
}
|
|
93
|
+
throw new Error(result.error ?? 'Failed to get agent details');
|
|
87
94
|
}
|
|
88
95
|
const { success: _success, ...agent } = result;
|
|
89
96
|
return { agent };
|
|
@@ -12,7 +12,7 @@ export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, presentTa
|
|
|
12
12
|
export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.js';
|
|
13
13
|
export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
|
|
14
14
|
export { GRANTS_CAPABILITIES, listGrantsCapability } from './grants.js';
|
|
15
|
-
export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, contextRequestCapability, accessRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, } from './context.js';
|
|
15
|
+
export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, contextRequestCapability, accessRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, explainRefusedRead, RESOURCE_HIDDEN_MESSAGE, RESOURCE_UNREADABLE_MESSAGE, type RefusedRead, } from './context.js';
|
|
16
16
|
export { CONNECTION_CAPABILITIES, connectionProxyCapability, requestConnectionCapability, } from './connections.js';
|
|
17
17
|
export { DISCOVERY_CAPABILITIES, agentSearchCapability, agentGetCapability, } from './discovery.js';
|
|
18
18
|
export { ARTIFACT_CAPABILITIES, recordArtifactCapability, listArtifactsCapability, findArtifactsCapability, type UnsearchedContext, shareArtifactCapability, attachArtifactCapability, uploadArtifactUrlCapability, completeArtifactFileCapability, downloadArtifactCapability, reextractArtifactCapability, } from './artifacts.js';
|
|
@@ -12,7 +12,7 @@ export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, presentTa
|
|
|
12
12
|
export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.js';
|
|
13
13
|
export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
|
|
14
14
|
export { GRANTS_CAPABILITIES, listGrantsCapability } from './grants.js';
|
|
15
|
-
export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, contextRequestCapability, accessRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, } from './context.js';
|
|
15
|
+
export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, contextRequestCapability, accessRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, explainRefusedRead, RESOURCE_HIDDEN_MESSAGE, RESOURCE_UNREADABLE_MESSAGE, } from './context.js';
|
|
16
16
|
export { CONNECTION_CAPABILITIES, connectionProxyCapability, requestConnectionCapability, } from './connections.js';
|
|
17
17
|
export { DISCOVERY_CAPABILITIES, agentSearchCapability, agentGetCapability, } from './discovery.js';
|
|
18
18
|
export { ARTIFACT_CAPABILITIES, recordArtifactCapability, listArtifactsCapability, findArtifactsCapability, shareArtifactCapability, attachArtifactCapability, uploadArtifactUrlCapability, completeArtifactFileCapability, downloadArtifactCapability, reextractArtifactCapability, } from './artifacts.js';
|
|
@@ -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.',
|
|
@@ -33,7 +33,9 @@ export class ContextOpenClient {
|
|
|
33
33
|
async post(path, body) {
|
|
34
34
|
const filled = ['artifactId', 'chatId', 'taskId', 'agreementId'].filter((key) => typeof body[key] === 'string' && body[key].trim());
|
|
35
35
|
if (filled.length !== 1) {
|
|
36
|
-
|
|
36
|
+
// A caller's input mistake, named in the caller's words: the shared
|
|
37
|
+
// INVALID_INPUT code, and no internal class name in the sentence.
|
|
38
|
+
throw Object.assign(new Error('Pass exactly one of artifactId, chatId, taskId, agreementId.'), { code: 'INVALID_INPUT' });
|
|
37
39
|
}
|
|
38
40
|
const url = `${this.baseUrl || getBackendUrl()}${path}`;
|
|
39
41
|
const res = await fetch(url, {
|
|
@@ -90,11 +90,6 @@ export declare class PaymentsClient {
|
|
|
90
90
|
holderId: string;
|
|
91
91
|
caveats?: unknown;
|
|
92
92
|
}): Promise<PaymentGrantEnvelope>;
|
|
93
|
-
attenuateGrant({ grantId, holderId, caveats, }: {
|
|
94
|
-
grantId: string;
|
|
95
|
-
holderId: string;
|
|
96
|
-
caveats?: unknown;
|
|
97
|
-
}): Promise<PaymentGrantEnvelope>;
|
|
98
93
|
revokeGrant(grantId: string): Promise<RevokeGrantResult>;
|
|
99
94
|
/**
|
|
100
95
|
* Live wallet grants the acting agent holds, via the unified GET /grants
|
|
@@ -79,12 +79,6 @@ export class PaymentsClient {
|
|
|
79
79
|
async issueGrant({ holderId, caveats }) {
|
|
80
80
|
return (await this._post('/payments/grants', { holderId, caveats }));
|
|
81
81
|
}
|
|
82
|
-
async attenuateGrant({ grantId, holderId, caveats, }) {
|
|
83
|
-
return (await this._post(`/payments/grants/${grantId}/attenuate`, {
|
|
84
|
-
holderId,
|
|
85
|
-
caveats,
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
88
82
|
async revokeGrant(grantId) {
|
|
89
83
|
return (await this._request('DELETE', `/payments/grants/${grantId}`, undefined));
|
|
90
84
|
}
|