@ziggs-ai/api-client 0.37.4 → 0.37.5
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 +0 -1
- package/dist/capabilities/context.js +0 -31
- package/dist/capabilities/index.d.ts +1 -1
- package/dist/capabilities/index.js +1 -1
- package/dist/capabilities/links.d.ts +3 -4
- package/dist/capabilities/links.js +5 -6
- package/dist/capabilities/mcpBriefs.js +1 -9
- package/dist/capabilities/nextCall.js +1 -8
- package/dist/http/ContextGrantsClient.d.ts +0 -12
- package/dist/http/ContextGrantsClient.js +0 -18
- package/dist/http/TaskClient.d.ts +2 -0
- package/dist/types.d.ts +14 -0
- package/package.json +1 -1
|
@@ -50,6 +50,5 @@ export declare const RESOURCE_UNREADABLE_MESSAGE = "This exists and you cannot r
|
|
|
50
50
|
export declare function explainRefusedRead(kind: 'agreement' | 'task' | 'chat' | 'artifact', id: string, env: CapabilityEnv): Promise<RefusedRead | null>;
|
|
51
51
|
export declare const openCapability: CapabilityDefinition;
|
|
52
52
|
export declare const accessExplainCapability: CapabilityDefinition;
|
|
53
|
-
export declare const contextRequestCapability: CapabilityDefinition;
|
|
54
53
|
export declare const accessRequestCapability: CapabilityDefinition;
|
|
55
54
|
export declare const CONTEXT_CAPABILITIES: CapabilityDefinition[];
|
|
@@ -391,36 +391,6 @@ export const accessExplainCapability = {
|
|
|
391
391
|
return presentOpenResult(result, env);
|
|
392
392
|
},
|
|
393
393
|
};
|
|
394
|
-
export const contextRequestCapability = {
|
|
395
|
-
key: 'context_request',
|
|
396
|
-
names: { sdk: 'context_request', mcp: 'ziggs_context_request' },
|
|
397
|
-
title: 'Ask an owner for artifact access',
|
|
398
|
-
descriptions: {
|
|
399
|
-
sdk: 'Ask a human owner for temporary read-only access to one artifact you were given a reference for. Use your existing chat with that owner. Creates an approval agreement; gives no access until the owner approves. You are the only recipient. After approval, open the original artifact. Never use a generic service agreement as a substitute for this access request.',
|
|
400
|
-
},
|
|
401
|
-
annotation: 'destructive', needsAgentId: true,
|
|
402
|
-
params: {
|
|
403
|
-
artifactId: { type: 'string', required: true },
|
|
404
|
-
chatId: { type: 'string', required: true },
|
|
405
|
-
ownerId: { type: 'string', required: true, description: 'Who to ask, from your work brief: workBrief.actingFor.customer.id or workBrief.actingFor.operator.id. Anyone else is refused, and the refusal lists who you can ask.' },
|
|
406
|
-
reason: { type: 'string', required: true, description: 'Purpose, including whom you will summarize the artifact to' },
|
|
407
|
-
durationHours: { type: 'number', description: 'Integer 1–168 hours after approval; default 24' },
|
|
408
|
-
idempotencyKey: { type: 'string', description: 'Reuse for the same request; do not create duplicate approval cards' },
|
|
409
|
-
},
|
|
410
|
-
handler: async (args, env) => {
|
|
411
|
-
for (const key of ['artifactId', 'chatId', 'ownerId', 'reason'])
|
|
412
|
-
if (typeof args[key] !== 'string' || !String(args[key]).trim())
|
|
413
|
-
throw new Error(`${key} is required`);
|
|
414
|
-
const durationHours = args.durationHours === undefined ? 24 : Number(args.durationHours);
|
|
415
|
-
if (!Number.isInteger(durationHours) || durationHours < 1 || durationHours > 168)
|
|
416
|
-
throw new Error('durationHours must be an integer between 1 and 168');
|
|
417
|
-
const creds = fullCreds(env);
|
|
418
|
-
const result = await new ContextGrantsClient(creds.operatorKey, creds.agentId, env.baseUrl).requestArtifactAccess(args.artifactId, {
|
|
419
|
-
chatId: args.chatId, ownerId: args.ownerId, reason: args.reason, durationHours,
|
|
420
|
-
}, { idempotencyKey: args.idempotencyKey, laneId: creds.laneId });
|
|
421
|
-
return { ...result, outcome: 'pending', state: 'requested', appUrl: `${(env.webUrl ?? 'https://ziggsai.com').replace(/\/$/, '')}/app/agreements/${encodeURIComponent(result.agreementId)}`, note: `${result.message ?? 'Waiting for the artifact owner.'} No access granted yet; open the original artifact only after approval.` };
|
|
422
|
-
},
|
|
423
|
-
};
|
|
424
394
|
/** A suggested request still needs a purpose; it is never a grant or an approval. */
|
|
425
395
|
function requestAccessAction(args, env) {
|
|
426
396
|
return {
|
|
@@ -543,7 +513,6 @@ export const CONTEXT_CAPABILITIES = [
|
|
|
543
513
|
openCapability,
|
|
544
514
|
accessExplainCapability,
|
|
545
515
|
accessRequestCapability,
|
|
546
|
-
contextRequestCapability,
|
|
547
516
|
contextDelegateCapability,
|
|
548
517
|
contextExpandReachCapability,
|
|
549
518
|
contextDiscoverGrantableCapability,
|
|
@@ -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,
|
|
15
|
+
export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, 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,
|
|
15
|
+
export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, 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';
|
|
@@ -5,10 +5,9 @@ export declare function webAppOrigin(env: CapabilityEnv): string;
|
|
|
5
5
|
*
|
|
6
6
|
* Opening a chat is itself the admission: the backend issues a standing from-now
|
|
7
7
|
* write grant to each side as it creates the room, so both delegates can
|
|
8
|
-
* read and post immediately.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* already exist (an older chat, an agreement, an org).
|
|
8
|
+
* read and post immediately. Sharing what already exists is artifact_share for
|
|
9
|
+
* one artifact, a chat_open invite for a room, or context_delegate for a slice
|
|
10
|
+
* of a grant the agent holds.
|
|
12
11
|
*/
|
|
13
12
|
export declare function linkIsReachOnly(env: CapabilityEnv): string;
|
|
14
13
|
export declare const listLinksCapability: CapabilityDefinition;
|
|
@@ -10,14 +10,13 @@ export function webAppOrigin(env) {
|
|
|
10
10
|
*
|
|
11
11
|
* Opening a chat is itself the admission: the backend issues a standing from-now
|
|
12
12
|
* write grant to each side as it creates the room, so both delegates can
|
|
13
|
-
* read and post immediately.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* already exist (an older chat, an agreement, an org).
|
|
13
|
+
* read and post immediately. Sharing what already exists is artifact_share for
|
|
14
|
+
* one artifact, a chat_open invite for a room, or context_delegate for a slice
|
|
15
|
+
* of a grant the agent holds.
|
|
17
16
|
*/
|
|
18
17
|
export function linkIsReachOnly(env) {
|
|
19
18
|
return env.surface === 'mcp'
|
|
20
|
-
? 'A link is reach-only — it shares no context on its own. Open a chat with the PERSON on the other side (ziggs_chat_open, participantId = that link\'s `peer.id`): delivery lands in their mailbox and whoever runs that side picks it up, which is not yours to choose. Use `peer.id`, never a principal out of `parties` — those are display faces, and chat_open refuses a face because it names no single party. Opening the room admits both sides to read and post from then on. To share context that already exists,
|
|
19
|
+
? 'A link is reach-only — it shares no context on its own. Open a chat with the PERSON on the other side (ziggs_chat_open, participantId = that link\'s `peer.id`): delivery lands in their mailbox and whoever runs that side picks it up, which is not yours to choose. Use `peer.id`, never a principal out of `parties` — those are display faces, and chat_open refuses a face because it names no single party. Opening the room admits both sides to read and post from then on. To share context that already exists, share one artifact with ziggs_artifact_share, invite them into a room you hold with ziggs_chat_open (chatId plus participantIds), or share a slice of a grant you hold with ziggs_context_delegate.'
|
|
21
20
|
: 'A link is reach-only — it shares no context on its own. Open a chat with the PERSON on the other side; delivery lands in their mailbox and whoever runs that side picks it up, which is not yours to choose. Opening the room admits both sides to it from then on. To share context that already exists, share a slice of a grant you hold with context_delegate, or ask the peer owner to issue one.';
|
|
22
21
|
}
|
|
23
22
|
const LINK_STATUSES = ['active', 'open', 'cancelled', 'all'];
|
|
@@ -84,7 +83,7 @@ export const listLinksCapability = {
|
|
|
84
83
|
readPlan.push(nextCall(env, 'chat_open', undefined, 'open a room with a linked peer: participantId is that link\'s `peer.id`. Do NOT pass a principal out of `parties` — those are display faces and chat_open refuses them'));
|
|
85
84
|
}
|
|
86
85
|
if (active.length) {
|
|
87
|
-
readPlan.push(nextCall(env, '
|
|
86
|
+
readPlan.push(nextCall(env, 'artifact_share', undefined, 'share context that already exists: a link does not share any on its own. One artifact with artifact_share; a room you hold by inviting them with chat_open (chatId plus participantIds)'));
|
|
88
87
|
}
|
|
89
88
|
return {
|
|
90
89
|
count: links.length,
|
|
@@ -137,14 +137,6 @@ const BRIEFS = {
|
|
|
137
137
|
does: 'Asks for access to an artifact, chat, agreement or task for this agent. recipientId names who decides (a refusal lists who you can ask); an artifact needs chatId.',
|
|
138
138
|
changes: 'creates a pending approval; grants nothing until approved',
|
|
139
139
|
},
|
|
140
|
-
ziggs_context_request: {
|
|
141
|
-
does: 'Asks an artifact’s owner for read access to it, for 1 to 168 hours.',
|
|
142
|
-
changes: 'creates a pending approval; grants nothing until approved',
|
|
143
|
-
},
|
|
144
|
-
ziggs_context_issue_grant: {
|
|
145
|
-
does: 'Admits another agent to a room. Agreement, org, artifact and task grants need your person’s authority.',
|
|
146
|
-
changes: 'admits it, pending until the people there consent',
|
|
147
|
-
},
|
|
148
140
|
ziggs_context_delegate: {
|
|
149
141
|
does: 'Gives another agent a narrower slice of a grant you hold.',
|
|
150
142
|
changes: 'grants it, or opens a request its owner approves (pending_approval)',
|
|
@@ -204,7 +196,7 @@ const BRIEFS = {
|
|
|
204
196
|
changes: 'the old steps are replaced',
|
|
205
197
|
},
|
|
206
198
|
ziggs_task_set_result: {
|
|
207
|
-
does: 'Closes a task as completed
|
|
199
|
+
does: 'Closes a task as completed or failed; the result is for the next agent, a person reads it in your conversation. The agreement stays active.',
|
|
208
200
|
changes: 'closes the task, proving nobody read or paid; the same idempotencyKey is a no-op',
|
|
209
201
|
},
|
|
210
202
|
ziggs_task_cancel: {
|
|
@@ -28,7 +28,6 @@ const REQUIRED_ARGS = {
|
|
|
28
28
|
agreement_subcontract: ['parentAgreementId', 'executorId', 'description'],
|
|
29
29
|
agreement_respond: ['agreementId'],
|
|
30
30
|
introduction_redeem: ['token'],
|
|
31
|
-
context_issue_grant: ['holderId', 'scopeKind', 'scopeId'],
|
|
32
31
|
artifact_share: ['artifactId', 'holderId'],
|
|
33
32
|
context_delegate: ['parentGrantId', 'holderId', 'scopeKind', 'scopeId', 'temporal'],
|
|
34
33
|
task_create: ['agreementId', 'description'],
|
|
@@ -59,7 +58,6 @@ const HTTP_BINDINGS = {
|
|
|
59
58
|
path: '/agreements/:agreementId/approvals/:partyId',
|
|
60
59
|
},
|
|
61
60
|
marketplace_view: { method: 'GET', path: '/marketplace/offers' },
|
|
62
|
-
context_issue_grant: { method: 'POST', path: '/context/grants' },
|
|
63
61
|
artifact_share: { method: 'POST', path: '/context/artifacts/:artifactId/share' },
|
|
64
62
|
context_delegate: { method: 'POST', path: '/context/grants/:parentGrantId/delegate' },
|
|
65
63
|
open: { method: 'POST', path: '/context/open' },
|
|
@@ -74,11 +72,9 @@ const HTTP_BINDINGS = {
|
|
|
74
72
|
};
|
|
75
73
|
/**
|
|
76
74
|
* Intentional surface exclusions. A ready next call has to exist as a tool
|
|
77
|
-
* on the calling surface
|
|
78
|
-
* issue grant (tool-surface-parity).
|
|
75
|
+
* on the calling surface (tool-surface-parity).
|
|
79
76
|
*/
|
|
80
77
|
const SURFACE_EXPOSURE = {
|
|
81
|
-
context_issue_grant: ['mcp'],
|
|
82
78
|
// The hosted SDK surface enumerates its own work with task_list and reads a
|
|
83
79
|
// task from the wake it arrived on; ziggs_task_get is the MCP delegate's
|
|
84
80
|
// one-task read. Naming it to an SDK agent would offer a tool it cannot call.
|
|
@@ -98,9 +94,6 @@ const MATERIAL_EFFECTS = {
|
|
|
98
94
|
introduction_redeem: {
|
|
99
95
|
relationship: 'a stranger redeem stages a link both humans must approve — it is not a live connection yet',
|
|
100
96
|
},
|
|
101
|
-
context_issue_grant: {
|
|
102
|
-
disclosure: 'issues a grant that widens who can read that scope',
|
|
103
|
-
},
|
|
104
97
|
link_propose: {
|
|
105
98
|
relationship: 'proposes a reach-only link; nothing is shared until they accept',
|
|
106
99
|
},
|
|
@@ -115,18 +115,6 @@ export declare class ContextGrantsClient {
|
|
|
115
115
|
idempotencyKey?: string;
|
|
116
116
|
laneId?: string;
|
|
117
117
|
}): Promise<AccessRequestResult>;
|
|
118
|
-
requestArtifactAccess(artifactId: string, input: {
|
|
119
|
-
chatId: string;
|
|
120
|
-
ownerId: string;
|
|
121
|
-
reason: string;
|
|
122
|
-
durationHours?: number;
|
|
123
|
-
}, opts?: {
|
|
124
|
-
idempotencyKey?: string;
|
|
125
|
-
laneId?: string;
|
|
126
|
-
}): Promise<{
|
|
127
|
-
status: 'pending_approval';
|
|
128
|
-
agreementId: string;
|
|
129
|
-
} & RequestSentTo>;
|
|
130
118
|
delegateGrant(parentGrantId: string, input: DelegateContextGrantInput, opts?: {
|
|
131
119
|
idempotencyKey?: string;
|
|
132
120
|
}): Promise<DelegateContextGrantResult>;
|
|
@@ -94,24 +94,6 @@ export class ContextGrantsClient {
|
|
|
94
94
|
}
|
|
95
95
|
return { status: 'pending_approval', agreementId: result.agreementId, ...common };
|
|
96
96
|
}
|
|
97
|
-
async requestArtifactAccess(artifactId, input, opts) {
|
|
98
|
-
const res = await fetch(`${this.baseUrl}/context/artifacts/${encodeURIComponent(artifactId)}/access-requests`, {
|
|
99
|
-
method: 'POST',
|
|
100
|
-
headers: buildOperatorHeaders(this.operatorKey, this.agentId, {
|
|
101
|
-
'content-type': 'application/json',
|
|
102
|
-
...(opts?.idempotencyKey ? { 'Idempotency-Key': opts.idempotencyKey } : {}),
|
|
103
|
-
...(opts?.laneId ? { 'x-ziggs-lane': opts.laneId } : {}),
|
|
104
|
-
}),
|
|
105
|
-
body: JSON.stringify(input),
|
|
106
|
-
});
|
|
107
|
-
const body = await res.text().catch(() => '');
|
|
108
|
-
if (!res.ok)
|
|
109
|
-
throwApiError(res, body, `requestArtifactAccess failed: ${res.status}`);
|
|
110
|
-
const result = JSON.parse(body);
|
|
111
|
-
if (result.status !== 'pending_approval' || !result.agreementId)
|
|
112
|
-
throw new Error('Expected a pending artifact access request');
|
|
113
|
-
return { status: 'pending_approval', agreementId: result.agreementId, ...sentToOf(result) };
|
|
114
|
-
}
|
|
115
97
|
async delegateGrant(parentGrantId, input, opts) {
|
|
116
98
|
const res = await fetch(`${this.baseUrl}/context/grants/${encodeURIComponent(parentGrantId)}/delegate`, {
|
|
117
99
|
method: 'POST',
|
|
@@ -48,6 +48,8 @@ export interface CreateTaskGraphNodeData {
|
|
|
48
48
|
assigneeId?: string;
|
|
49
49
|
waitsOn?: string[];
|
|
50
50
|
joinKind?: 'all' | 'any';
|
|
51
|
+
/** A yes/no question over the steps this one waits on; it runs only on yes. */
|
|
52
|
+
runIf?: string;
|
|
51
53
|
}
|
|
52
54
|
export interface CreateTaskGraphData {
|
|
53
55
|
nodes: CreateTaskGraphNodeData[];
|
package/dist/types.d.ts
CHANGED
|
@@ -112,6 +112,20 @@ export interface Task {
|
|
|
112
112
|
} | null;
|
|
113
113
|
graphNodeId?: string | null;
|
|
114
114
|
heldByGraphReview?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* A graph step that runs only if a yes/no question holds over the steps it
|
|
117
|
+
* waits on. Once asked: `run`, `skipped` (closed cancelled without running),
|
|
118
|
+
* `held` (waiting for the buyer to acknowledge its plan) or `buyer_run`.
|
|
119
|
+
*/
|
|
120
|
+
runIf?: {
|
|
121
|
+
question: string;
|
|
122
|
+
outcome?: 'run' | 'skipped' | 'held' | 'buyer_run';
|
|
123
|
+
answer?: 'yes' | 'no' | null;
|
|
124
|
+
confidence?: number | null;
|
|
125
|
+
reason?: string;
|
|
126
|
+
decidedAt?: string;
|
|
127
|
+
decidedBy?: string | null;
|
|
128
|
+
} | null;
|
|
115
129
|
plan?: {
|
|
116
130
|
steps?: PlanStep[];
|
|
117
131
|
};
|