@ziggs-ai/api-client 0.6.0 → 0.6.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.
- package/dist/capabilities/links.d.ts +10 -1
- package/dist/capabilities/links.js +37 -7
- package/dist/http/ArtifactsClient.d.ts +17 -1
- package/dist/http/ArtifactsClient.js +20 -2
- package/dist/http/InboxClient.d.ts +4 -0
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +3 -1
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -11,11 +11,34 @@ function webAppOrigin(env) {
|
|
|
11
11
|
* own assistant, which then connects itself and claims the invite. The claim
|
|
12
12
|
* URL alone only helps someone who already has Ziggs and an assistant wired
|
|
13
13
|
* up, so hand the caller both and let it pick per recipient.
|
|
14
|
+
*
|
|
15
|
+
* The account question comes FIRST, and the answer is always the claim URL —
|
|
16
|
+
* never 'Create account' on the MCP consent screen. Signup is invite-gated and
|
|
17
|
+
* only the claim URL carries the invite that waives it; the consent screen's
|
|
18
|
+
* signup button carries nothing, and nothing in an MCP OAuth handshake can
|
|
19
|
+
* carry it for them (the client builds its authorize request from RFC 8414/9728
|
|
20
|
+
* discovery, so a query param on the pasted server URL never reaches us). So a
|
|
21
|
+
* recipient new to Ziggs who lets their assistant lead used to hit a hard 403
|
|
22
|
+
* with no way back. Ordering is the whole fix: the URL both signs them up AND
|
|
23
|
+
* claims, leaving the assistant less to do, not more.
|
|
24
|
+
*
|
|
25
|
+
* Keep in step with the web app's copy of this text (frontend
|
|
26
|
+
* src/lib/links/inviteShare.ts) — same instructions, two surfaces.
|
|
14
27
|
*/
|
|
15
28
|
function invitePasteText(agreementId, claimUrl) {
|
|
16
29
|
return [
|
|
17
30
|
'Connect me to Ziggs and accept this agent link invite.',
|
|
18
31
|
'',
|
|
32
|
+
'First ask me: do I already have a Ziggs account?',
|
|
33
|
+
'',
|
|
34
|
+
` If no, or I am not sure — open this in a browser: ${claimUrl}`,
|
|
35
|
+
' That creates my account and accepts the link in one step, and needs no',
|
|
36
|
+
" invite code. Do NOT send me to 'Create account' on the Ziggs consent",
|
|
37
|
+
' screen instead — signup there is gated and will reject me. Once I am',
|
|
38
|
+
' back, continue from step 1 to connect yourself; step 2 is already done.',
|
|
39
|
+
'',
|
|
40
|
+
' If yes — start at step 1.',
|
|
41
|
+
'',
|
|
19
42
|
`1. Add this MCP server: ${ZIGGS_MCP_URL}`,
|
|
20
43
|
' It speaks Streamable HTTP and uses OAuth — pasting the URL is enough,',
|
|
21
44
|
' but I may need to approve a consent screen in my browser.',
|
|
@@ -24,8 +47,6 @@ function invitePasteText(agreementId, claimUrl) {
|
|
|
24
47
|
'',
|
|
25
48
|
'If you cannot add MCP servers yourself, tell me exactly where to paste that',
|
|
26
49
|
"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
50
|
].join('\n');
|
|
30
51
|
}
|
|
31
52
|
/**
|
|
@@ -49,11 +70,20 @@ export function linkSummary(a) {
|
|
|
49
70
|
createdAt: a.createdAt,
|
|
50
71
|
};
|
|
51
72
|
}
|
|
52
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* A link is reach-only — the follow-up move differs by surface tool names.
|
|
75
|
+
*
|
|
76
|
+
* Opening a chat is itself the admission: the backend issues a standing from-now
|
|
77
|
+
* chat grant to every agent member as it creates the room, so both delegates can
|
|
78
|
+
* read and post immediately. Do NOT tell agents to follow chat_open with an
|
|
79
|
+
* issue_grant on that same new chat — that only mints a duplicate grant carrying
|
|
80
|
+
* the default 30-day expiry. issue_grant / context_delegate are for scopes that
|
|
81
|
+
* already exist (an older chat, an agreement, an org).
|
|
82
|
+
*/
|
|
53
83
|
export function linkIsReachOnly(env) {
|
|
54
84
|
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
|
|
85
|
+
? '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.'
|
|
86
|
+
: '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
87
|
}
|
|
58
88
|
const LINK_STATUSES = ['active', 'open', 'cancelled', 'all'];
|
|
59
89
|
/**
|
|
@@ -106,8 +136,8 @@ export const createLinkInviteCapability = {
|
|
|
106
136
|
seatsRemaining: seats - (agreement.linkInvite?.claimsUsed ?? 0),
|
|
107
137
|
pasteText: invitePasteText(agreement.agreementId, claimUrl),
|
|
108
138
|
message: env.surface === 'mcp'
|
|
109
|
-
? `Open link invite created, ${seatNote}. Give the human BOTH forms and say which is which: claimUrl
|
|
110
|
-
: `Open link invite created, ${seatNote}.
|
|
139
|
+
? `Open link invite created, ${seatNote}. Give the human BOTH forms and say which is which: claimUrl is the one that always works — a recipient with no Ziggs account signs up straight from it, no beta code needed, and it accepts the link in the same step. pasteText is for a recipient who would rather their own assistant do the wiring; it starts by sending them to claimUrl if they have no account yet, since signup on the MCP consent screen is gated and would reject them. Either way the recipient needs their own assistant connected before the link carries anything. No agent id needed on either side.`
|
|
140
|
+
: `Open link invite created, ${seatNote}. claimUrl is the one that always works — a recipient with no Ziggs account signs up straight from it, no beta code needed, and it accepts the link in the same step. pasteText is for a recipient whose own assistant does the wiring; it sends them to claimUrl first if they have no account, since signup on the consent screen is gated. Either way they need an assistant connected before the link carries anything. No agent id needed on either side. Revoke with agreement_revoke to disable.`,
|
|
111
141
|
agreement: linkSummary(agreement),
|
|
112
142
|
};
|
|
113
143
|
},
|
|
@@ -36,6 +36,22 @@ export interface WriteArtifactInput {
|
|
|
36
36
|
* writes. `visibility: 'agent-private'` is the new home for agent thoughts —
|
|
37
37
|
* they persist, are searchable, but are not visible to other chat parties.
|
|
38
38
|
*/
|
|
39
|
+
/**
|
|
40
|
+
* ZIG-1032 — turn a runtime lane id into a scope the backend can accept.
|
|
41
|
+
*
|
|
42
|
+
* A task with no origin chat runs on the lane `agrn-<agreementId>` (see
|
|
43
|
+
* AgentHost.laneSessionIdForTask). That is a routing key, not a chat: no such
|
|
44
|
+
* chat row exists, so passing it as `chatId` made every breadcrumb and recorded
|
|
45
|
+
* thought on an agreement lane come back 403 "not authorized for this scope" —
|
|
46
|
+
* a fictional scope reading like an auth failure. The work is agreement-scoped,
|
|
47
|
+
* so say so; same rule ZIG-924 settled for deliverables.
|
|
48
|
+
*/
|
|
49
|
+
export declare const AGREEMENT_LANE_PREFIX = "agrn-";
|
|
50
|
+
export declare function artifactScopeForSession(sessionId: string): {
|
|
51
|
+
chatId: string;
|
|
52
|
+
} | {
|
|
53
|
+
agreementId: string;
|
|
54
|
+
};
|
|
39
55
|
export declare class ArtifactsClient {
|
|
40
56
|
private readonly operatorKey;
|
|
41
57
|
private readonly agentId?;
|
|
@@ -54,7 +70,7 @@ export declare class ArtifactsClient {
|
|
|
54
70
|
* endpoint is updated to accept `visibility`, this falls back to logging
|
|
55
71
|
* locally (operators can still wire their own sink).
|
|
56
72
|
*/
|
|
57
|
-
recordThought(
|
|
73
|
+
recordThought(sessionId: string, text: string, opts?: {
|
|
58
74
|
idempotencyKey?: string;
|
|
59
75
|
}): Promise<void>;
|
|
60
76
|
write(input: WriteArtifactInput): Promise<void>;
|
|
@@ -7,6 +7,23 @@ import { buildOperatorHeaders } from './operatorHeaders.js';
|
|
|
7
7
|
* writes. `visibility: 'agent-private'` is the new home for agent thoughts —
|
|
8
8
|
* they persist, are searchable, but are not visible to other chat parties.
|
|
9
9
|
*/
|
|
10
|
+
/**
|
|
11
|
+
* ZIG-1032 — turn a runtime lane id into a scope the backend can accept.
|
|
12
|
+
*
|
|
13
|
+
* A task with no origin chat runs on the lane `agrn-<agreementId>` (see
|
|
14
|
+
* AgentHost.laneSessionIdForTask). That is a routing key, not a chat: no such
|
|
15
|
+
* chat row exists, so passing it as `chatId` made every breadcrumb and recorded
|
|
16
|
+
* thought on an agreement lane come back 403 "not authorized for this scope" —
|
|
17
|
+
* a fictional scope reading like an auth failure. The work is agreement-scoped,
|
|
18
|
+
* so say so; same rule ZIG-924 settled for deliverables.
|
|
19
|
+
*/
|
|
20
|
+
export const AGREEMENT_LANE_PREFIX = 'agrn-';
|
|
21
|
+
export function artifactScopeForSession(sessionId) {
|
|
22
|
+
if (sessionId.startsWith(AGREEMENT_LANE_PREFIX)) {
|
|
23
|
+
return { agreementId: sessionId.slice(AGREEMENT_LANE_PREFIX.length) };
|
|
24
|
+
}
|
|
25
|
+
return { chatId: sessionId };
|
|
26
|
+
}
|
|
10
27
|
export class ArtifactsClient {
|
|
11
28
|
operatorKey;
|
|
12
29
|
agentId;
|
|
@@ -49,9 +66,10 @@ export class ArtifactsClient {
|
|
|
49
66
|
* endpoint is updated to accept `visibility`, this falls back to logging
|
|
50
67
|
* locally (operators can still wire their own sink).
|
|
51
68
|
*/
|
|
52
|
-
async recordThought(
|
|
69
|
+
async recordThought(sessionId, text, opts = {}) {
|
|
70
|
+
// ZIG-1032: `sessionId` may be an agreement lane, which is not a chat.
|
|
53
71
|
return this.write({
|
|
54
|
-
|
|
72
|
+
...artifactScopeForSession(sessionId),
|
|
55
73
|
text,
|
|
56
74
|
content_type: 'thought',
|
|
57
75
|
visibility: 'agent-private',
|
|
@@ -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
|
}
|
package/dist/http/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from './agreementFlows.js';
|
|
|
5
5
|
export * from './ChatClient.js';
|
|
6
6
|
export { MessagesClient } from './MessagesClient.js';
|
|
7
7
|
export type { ListMessagesOptions, ListMessagesResult } from './MessagesClient.js';
|
|
8
|
-
export { ArtifactsClient } from './ArtifactsClient.js';
|
|
8
|
+
export { ArtifactsClient, artifactScopeForSession, AGREEMENT_LANE_PREFIX, } from './ArtifactsClient.js';
|
|
9
9
|
export type { ArtifactVisibility, ListArtifactsOptions, ListArtifactsQuery, ListArtifactsResult, WriteArtifactInput, } from './ArtifactsClient.js';
|
|
10
10
|
export { ContextReadClient } from './ContextReadClient.js';
|
|
11
11
|
export type { ContextReadType, ContextReadQuery, ContextReadEnvelope, ContextSnapshotResult, } from './ContextReadClient.js';
|
package/dist/http/index.js
CHANGED
|
@@ -4,7 +4,9 @@ export * from './MarketplaceClient.js';
|
|
|
4
4
|
export * from './agreementFlows.js';
|
|
5
5
|
export * from './ChatClient.js';
|
|
6
6
|
export { MessagesClient } from './MessagesClient.js';
|
|
7
|
-
export { ArtifactsClient
|
|
7
|
+
export { ArtifactsClient,
|
|
8
|
+
// ZIG-1032: agreement lanes are not chats — callers scope artifact writes with this.
|
|
9
|
+
artifactScopeForSession, AGREEMENT_LANE_PREFIX, } from './ArtifactsClient.js';
|
|
8
10
|
export { ContextReadClient } from './ContextReadClient.js';
|
|
9
11
|
export { ContextDiscoveryClient } from './ContextDiscoveryClient.js';
|
|
10
12
|
export { GrantsClient } from './GrantsClient.js';
|