@ziggs-ai/api-client 0.36.3 → 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.
@@ -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,6 +322,32 @@ 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' },
@@ -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
- throw new Error(result.error ?? 'agent not found');
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';
@@ -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
- throw new Error('ContextOpenClient: pass exactly one of artifactId, chatId, taskId, agreementId');
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.36.3",
3
+ "version": "0.36.4",
4
4
  "description": "HTTP and WebSocket client for the Ziggs backend API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",