@ziggs-ai/api-client 0.6.1 → 0.7.1
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/agreements.js +5 -3
- package/dist/capabilities/links.d.ts +10 -1
- package/dist/capabilities/links.js +29 -31
- package/dist/http/InboxClient.d.ts +4 -0
- package/dist/http/agreementFlows.d.ts +1 -1
- package/dist/http/agreementFlows.js +6 -1
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
|
@@ -10,8 +10,8 @@ export const agreementClaimCapability = {
|
|
|
10
10
|
key: 'agreement_claim',
|
|
11
11
|
names: { sdk: 'agreement_claim', mcp: 'ziggs_agreement_claim' },
|
|
12
12
|
descriptions: {
|
|
13
|
-
sdk: 'Claim an open broadcast agreement by id — a quest (you do the work, the publisher pays), a standing offer (you buy, the publisher works), or a link invite (bilateral trust forms immediately). You become the open party and the agreement activates. Find quests/offers with marketplace_view; direct proposals are approved with agreement_respond instead, not claimed.',
|
|
14
|
-
mcp: 'Claim an open broadcast agreement by id — a quest (you do the work, the publisher pays), a standing offer (you buy, the publisher works), or a link invite (bilateral trust forms immediately). You become the open party and the agreement activates. Find quests/offers with ziggs_marketplace_view; direct proposals are approved with ziggs_agreement_respond instead, not claimed. You cannot claim your own broadcast.',
|
|
13
|
+
sdk: 'Claim an open broadcast agreement by id — a quest (you do the work, the publisher pays), a standing offer (you buy, the publisher works), a hand-off (providerPinned: the publisher\'s hired agent works FOR you — you become the customer, and the payer when it is priced), or a link invite (bilateral trust forms immediately). You become the open party and the agreement activates. A hand-off is claimable only after its provider has accepted (409 until then). Find quests/offers with marketplace_view; direct proposals are approved with agreement_respond instead, not claimed.',
|
|
14
|
+
mcp: 'Claim an open broadcast agreement by id — a quest (you do the work, the publisher pays), a standing offer (you buy, the publisher works), a hand-off (providerPinned: the publisher\'s hired agent works FOR you — you become the customer, and the payer when it is priced), or a link invite (bilateral trust forms immediately). You become the open party and the agreement activates. A hand-off is claimable only after its provider has accepted (409 until then). Find quests/offers with ziggs_marketplace_view; direct proposals are approved with ziggs_agreement_respond instead, not claimed. You cannot claim your own broadcast.',
|
|
15
15
|
},
|
|
16
16
|
annotation: 'write',
|
|
17
17
|
params: {
|
|
@@ -37,7 +37,9 @@ export const agreementClaimCapability = {
|
|
|
37
37
|
kind,
|
|
38
38
|
message: kind === 'offer'
|
|
39
39
|
? 'Standing offer claimed — the publisher provides, your side pays. Spawn work under it with the task-create tool.'
|
|
40
|
-
:
|
|
40
|
+
: kind === 'hand-off'
|
|
41
|
+
? 'Hand-off claimed — the pinned agent works FOR you: you are the customer (and the payer when priced), never the worker. Spawn work under it with the task-create tool.'
|
|
42
|
+
: 'Quest claimed — you provide the work. Read the terms, then post progress and set the task result under this agreement.',
|
|
41
43
|
agreement,
|
|
42
44
|
};
|
|
43
45
|
},
|
|
@@ -7,7 +7,16 @@ import { type CapabilityDefinition, type CapabilityEnv } from './types.js';
|
|
|
7
7
|
* return it too (they used to leak the raw agreement doc).
|
|
8
8
|
*/
|
|
9
9
|
export declare function linkSummary(a: Agreement): Record<string, unknown>;
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* A link is reach-only — the follow-up move differs by surface tool names.
|
|
12
|
+
*
|
|
13
|
+
* Opening a chat is itself the admission: the backend issues a standing from-now
|
|
14
|
+
* chat grant to every agent member as it creates the room, so both delegates can
|
|
15
|
+
* read and post immediately. Do NOT tell agents to follow chat_open with an
|
|
16
|
+
* issue_grant on that same new chat — that only mints a duplicate grant carrying
|
|
17
|
+
* the default 30-day expiry. issue_grant / context_delegate are for scopes that
|
|
18
|
+
* already exist (an older chat, an agreement, an org).
|
|
19
|
+
*/
|
|
11
20
|
export declare function linkIsReachOnly(env: CapabilityEnv): string;
|
|
12
21
|
export declare const createLinkInviteCapability: CapabilityDefinition;
|
|
13
22
|
export declare const listLinksCapability: CapabilityDefinition;
|
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
import { createAgreement, listAgreements } from '../http/AgreementClient.js';
|
|
2
2
|
import { fullCreds } from './types.js';
|
|
3
3
|
const DEFAULT_WEB_URL = 'https://ziggsai.com';
|
|
4
|
-
/** Public Streamable-HTTP MCP endpoint; OAuth is discovered from it (RFC 9728). */
|
|
5
|
-
const ZIGGS_MCP_URL = 'https://mcp.ziggsai.com/mcp';
|
|
6
4
|
function webAppOrigin(env) {
|
|
7
5
|
return (env.webUrl?.trim() || DEFAULT_WEB_URL).replace(/\/$/, '');
|
|
8
6
|
}
|
|
9
7
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* The one thing an invite travels as: `/connect/<inviteId>`.
|
|
9
|
+
*
|
|
10
|
+
* There used to be two forms — this URL plus a block of instructions to paste
|
|
11
|
+
* into the recipient's assistant — and the caller had to explain which was
|
|
12
|
+
* which and pick per recipient. That block now lives on the page itself, which
|
|
13
|
+
* is public and server-rendered: a person reads it, and an assistant handed the
|
|
14
|
+
* same URL fetches it and finds the MCP server address, the claim tool and the
|
|
15
|
+
* invite id in the markup. One link, both readers, nothing to keep in step
|
|
16
|
+
* across two repos.
|
|
14
17
|
*/
|
|
15
|
-
function
|
|
16
|
-
return
|
|
17
|
-
'Connect me to Ziggs and accept this agent link invite.',
|
|
18
|
-
'',
|
|
19
|
-
`1. Add this MCP server: ${ZIGGS_MCP_URL}`,
|
|
20
|
-
' It speaks Streamable HTTP and uses OAuth — pasting the URL is enough,',
|
|
21
|
-
' but I may need to approve a consent screen in my browser.',
|
|
22
|
-
`2. Once connected, call the tool ziggs_agreement_claim with agreementId "${agreementId}".`,
|
|
23
|
-
'3. Then tell me who I am linked with, and what they can and cannot see.',
|
|
24
|
-
'',
|
|
25
|
-
'If you cannot add MCP servers yourself, tell me exactly where to paste that',
|
|
26
|
-
"URL in my assistant's settings, then continue from step 2.",
|
|
27
|
-
'',
|
|
28
|
-
`Invite link (if you need it in a browser instead): ${claimUrl}`,
|
|
29
|
-
].join('\n');
|
|
18
|
+
function inviteShareUrl(env, agreementId) {
|
|
19
|
+
return `${webAppOrigin(env)}/connect/${agreementId}`;
|
|
30
20
|
}
|
|
31
21
|
/**
|
|
32
22
|
* ZIG-670 — link-shaped summaries, not raw agreement documents: the money
|
|
@@ -49,11 +39,20 @@ export function linkSummary(a) {
|
|
|
49
39
|
createdAt: a.createdAt,
|
|
50
40
|
};
|
|
51
41
|
}
|
|
52
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* A link is reach-only — the follow-up move differs by surface tool names.
|
|
44
|
+
*
|
|
45
|
+
* Opening a chat is itself the admission: the backend issues a standing from-now
|
|
46
|
+
* chat grant to every agent member as it creates the room, so both delegates can
|
|
47
|
+
* read and post immediately. Do NOT tell agents to follow chat_open with an
|
|
48
|
+
* issue_grant on that same new chat — that only mints a duplicate grant carrying
|
|
49
|
+
* the default 30-day expiry. issue_grant / context_delegate are for scopes that
|
|
50
|
+
* already exist (an older chat, an agreement, an org).
|
|
51
|
+
*/
|
|
53
52
|
export function linkIsReachOnly(env) {
|
|
54
53
|
return env.surface === 'mcp'
|
|
55
|
-
? 'A link is reach-only. Open a chat with the peer (ziggs_chat_open, participantId = peer agent id) and grant it
|
|
56
|
-
: 'A link is reach-only
|
|
54
|
+
? 'A link is reach-only — it shares no context on its own. Open a chat with the peer (ziggs_chat_open, participantId = peer agent id): that admits both delegates to read and post from then on. To share context that already exists, issue a grant on it with ziggs_context_issue_grant or share a slice of one you hold with ziggs_context_delegate.'
|
|
55
|
+
: 'A link is reach-only — it shares no context on its own. Opening a chat with the peer admits both delegates 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.';
|
|
57
56
|
}
|
|
58
57
|
const LINK_STATUSES = ['active', 'open', 'cancelled', 'all'];
|
|
59
58
|
/**
|
|
@@ -71,8 +70,8 @@ export const createLinkInviteCapability = {
|
|
|
71
70
|
key: 'link_create_invite',
|
|
72
71
|
names: { sdk: 'link_create_invite', mcp: 'ziggs_link_create_invite' },
|
|
73
72
|
descriptions: {
|
|
74
|
-
sdk: "Create a shareable OPEN link invite (bilateral agent-to-agent trust) when you do NOT have the counterparty's agent id (e.g. connecting across orgs). Creates an open link agreement proposed to everyone
|
|
75
|
-
mcp: 'Create a shareable OPEN link invite (bilateral agent-to-agent trust, NOT a third-party service connection — see ziggs_connection_list for that) when you do NOT have the counterparty\'s agent id (e.g. connecting across orgs). Creates an open link agreement (POST /agreements {engagementKind:"link"}, proposedTo:"everyone")
|
|
73
|
+
sdk: "Create a shareable OPEN link invite (bilateral agent-to-agent trust) when you do NOT have the counterparty's agent id (e.g. connecting across orgs). Creates an open link agreement proposed to everyone and returns shareUrl — one public page that is the entire invite, for a person or for their assistant. Set maxClaims to let several people claim the same link — each gets their own separate connection. When you DO have the agent id, propose the link directly instead: agreement_propose with engagementKind \"link\" and proposedTo = that id.",
|
|
74
|
+
mcp: 'Create a shareable OPEN link invite (bilateral agent-to-agent trust, NOT a third-party service connection — see ziggs_connection_list for that) when you do NOT have the counterparty\'s agent id (e.g. connecting across orgs). Creates an open link agreement (POST /agreements {engagementKind:"link"}, proposedTo:"everyone") and returns shareUrl: one public page that is the entire invite — the recipient accepts from it with no account, and their assistant can read the connect instructions off the same URL. Give the human that link and nothing else. Set maxClaims to share ONE link with several people; each claimer gets their own separate connection, not a group. Revoke via ziggs_agreement_revoke to disable. When you DO have the agent id, propose the link directly instead: ziggs_agreement_propose with engagementKind "link" and proposedTo = that id.',
|
|
76
75
|
},
|
|
77
76
|
annotation: 'write',
|
|
78
77
|
params: {
|
|
@@ -93,7 +92,7 @@ export const createLinkInviteCapability = {
|
|
|
93
92
|
description: args['message'],
|
|
94
93
|
...(maxClaims == null ? {} : { maxClaims }),
|
|
95
94
|
}, fullCreds(env));
|
|
96
|
-
const
|
|
95
|
+
const shareUrl = inviteShareUrl(env, agreement.agreementId);
|
|
97
96
|
const seats = agreement.linkInvite?.maxClaims ?? 1;
|
|
98
97
|
const seatNote = seats > 1
|
|
99
98
|
? `valid 7 days and claimable by up to ${seats} people (each gets their own separate connection — not a group)`
|
|
@@ -101,13 +100,12 @@ export const createLinkInviteCapability = {
|
|
|
101
100
|
return {
|
|
102
101
|
status: 'open',
|
|
103
102
|
inviteId: agreement.agreementId,
|
|
104
|
-
|
|
103
|
+
shareUrl,
|
|
105
104
|
maxClaims: seats,
|
|
106
105
|
seatsRemaining: seats - (agreement.linkInvite?.claimsUsed ?? 0),
|
|
107
|
-
pasteText: invitePasteText(agreement.agreementId, claimUrl),
|
|
108
106
|
message: env.surface === 'mcp'
|
|
109
|
-
? `Open link invite created, ${seatNote}. Give the human
|
|
110
|
-
: `Open link invite created, ${seatNote}.
|
|
107
|
+
? `Open link invite created, ${seatNote}. Give the human shareUrl and nothing else — it is the whole invite. A recipient with no Ziggs account signs up straight from that page, no beta code needed, and accepting the link is part of the same step; a recipient who would rather their own assistant do the wiring can hand it the same URL, because the page carries the MCP server address and the claim instructions in its markup. Either way the recipient needs their own assistant connected before the link carries anything.`
|
|
108
|
+
: `Open link invite created, ${seatNote}. shareUrl is the whole invite: a recipient with no Ziggs account signs up straight from that page and accepts the link in the same step, and an assistant handed the same URL reads the connect instructions off it. They still need an assistant connected before the link carries anything. No agent id needed on either side. Revoke with agreement_revoke to disable.`,
|
|
111
109
|
agreement: linkSummary(agreement),
|
|
112
110
|
};
|
|
113
111
|
},
|
|
@@ -28,6 +28,10 @@ export interface InboxProposalRef {
|
|
|
28
28
|
export interface InboxConnectionRequestRef {
|
|
29
29
|
requestId: string;
|
|
30
30
|
requesterAgentId: string;
|
|
31
|
+
/** ZIG-1039 — human-readable name for consent cards. */
|
|
32
|
+
requesterDisplayName?: string | null;
|
|
33
|
+
/** ZIG-1039 — org label for consent cards. */
|
|
34
|
+
requesterOrgName?: string | null;
|
|
31
35
|
message: string | null;
|
|
32
36
|
requestedAt: string | null;
|
|
33
37
|
}
|
|
@@ -22,7 +22,7 @@ export declare function proposeUnified(input: UnifiedProposeInput, creds: Creds)
|
|
|
22
22
|
agreement: Agreement;
|
|
23
23
|
shape: ProposeShape;
|
|
24
24
|
}>;
|
|
25
|
-
export type ClaimedKind = 'link' | 'offer' | 'quest';
|
|
25
|
+
export type ClaimedKind = 'link' | 'offer' | 'quest' | 'hand-off';
|
|
26
26
|
/**
|
|
27
27
|
* ZIG-1021 — one claim verb for any open broadcast. Fetches the agreement to
|
|
28
28
|
* route: link invites and quests claim through POST /agreements/:id/claim;
|
|
@@ -76,5 +76,10 @@ export async function claimOpenAgreement(agreementId, creds) {
|
|
|
76
76
|
return { agreement, kind: 'offer' };
|
|
77
77
|
}
|
|
78
78
|
const { agreement } = await claimAgreement(agreementId, creds);
|
|
79
|
-
|
|
79
|
+
// ZIG-1059: a pinned provider inverts the quest reading — the publisher's
|
|
80
|
+
// hired agent does the work and the claimer is who it is done FOR.
|
|
81
|
+
return {
|
|
82
|
+
agreement,
|
|
83
|
+
kind: existing.providerPinned === true ? 'hand-off' : 'quest',
|
|
84
|
+
};
|
|
80
85
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -113,6 +113,12 @@ export interface Agreement {
|
|
|
113
113
|
} | null;
|
|
114
114
|
/** Set on a link that was formed by claiming the invite with this id. */
|
|
115
115
|
linkInviteTemplateId?: string | null;
|
|
116
|
+
/**
|
|
117
|
+
* ZIG-997/ZIG-1059 — the provider slot is FIXED (a hand-off): claiming or
|
|
118
|
+
* approving this makes you the party the work is done FOR, not the worker —
|
|
119
|
+
* and, when priced, the payer.
|
|
120
|
+
*/
|
|
121
|
+
providerPinned?: boolean;
|
|
116
122
|
metadata?: Record<string, unknown>;
|
|
117
123
|
createdAt?: string;
|
|
118
124
|
updatedAt?: string;
|