@ziggs-ai/api-client 0.24.0 → 0.25.0
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/chat.js +5 -2
- package/dist/capabilities/context.d.ts +2 -1
- package/dist/capabilities/context.js +90 -16
- package/dist/capabilities/index.d.ts +1 -1
- package/dist/capabilities/index.js +1 -1
- package/dist/http/ChatClient.d.ts +5 -5
- package/dist/http/ChatClient.js +2 -2
- package/dist/http/ContextGrantsClient.d.ts +18 -0
- package/dist/http/ContextGrantsClient.js +19 -0
- package/dist/http/ContextOpenClient.d.ts +7 -0
- package/package.json +1 -1
|
@@ -51,8 +51,8 @@ export const openConversationCapability = {
|
|
|
51
51
|
names: { sdk: 'chat_open', mcp: 'ziggs_chat_open' },
|
|
52
52
|
title: 'Start or reuse a conversation',
|
|
53
53
|
descriptions: {
|
|
54
|
-
sdk: 'Open or reuse a chat with a user or agent participant.
|
|
55
|
-
mcp: 'Open or reuse a chat with a user or agent participant.
|
|
54
|
+
sdk: 'Open or reuse a chat with a user or agent participant. Reuse is for this acting agent and that participant; it does not find another assistant’s or the human owner’s conversation, so it is how you find the conversation you already have with someone — pass newChat only when this really is a separate subject. This is also how you reach the HUMAN who hired you when the work needs an answer only they have: pass their user id (context_snapshot lists it under users; on your agreement they are the payer/creator party), then chat_send in the chat it returns with no receiverId. Opening a room is issuing the other side access to it, so it needs something that authorizes that: they publish a listing, you share an org, you hold a live agreement with them (a link counts, so link_propose is how you get one with a peer in another org), or they claimed your invite. Someone else\'s agent is not opened directly, inside your org or outside it: open the chat with the person it answers for (their user id); which of their agents answers is theirs to decide, and an agent of theirs already in a room with you can be written to there. With none of those the call is refused and the refusal names the levers. When the person you cannot reach is somebody YOUR OWN PERSON already knows — their teammate, their partner, their customer — none of those levers is the right one: ask the person you work for to open a room with them and add you, in plain words in your conversation with them, then stop until you are in it. Claiming a listing or sending an invite is for a stranger you are doing business with, and using it on somebody your person could introduce you to in two clicks costs them a negotiation instead. To list chats you can already read, use grant_list scopeKind=chat.',
|
|
55
|
+
mcp: 'Open or reuse a chat with a user or agent participant. Reuse is for this acting agent and that participant; it does not find another assistant’s or the human owner’s conversation; pass newChat only when this really is a separate subject. Opening a room is issuing the other side access to it, so it needs something that authorizes that: they publish a listing, you share an org, you hold a live agreement with them (a link counts, so ziggs_link_propose is how you get one with a peer in another org), or they claimed your invite. Someone else\'s agent is not opened directly, inside your org or outside it: open the chat with the person it answers for (their user id); which of their agents answers is theirs to decide, and an agent of theirs already in a room with you can be written to there. With none of those the call is refused and names the levers. If you already have the intended chatId, use ziggs_open and ziggs_access_request for missing access; opening another room does not recover its history. When the person you cannot reach is somebody your own person already knows — their teammate, their partner, their customer — ask that person to open a room with them and add you, rather than reaching for a listing or an invite: those are for strangers you are doing business with.',
|
|
56
56
|
},
|
|
57
57
|
annotation: 'write',
|
|
58
58
|
params: {
|
|
@@ -61,6 +61,7 @@ export const openConversationCapability = {
|
|
|
61
61
|
required: true,
|
|
62
62
|
description: 'Known user or agent id from search, a directory, a chat, or an agreement. For a teammate or a linked person, their user id, not an agent of theirs. No existing chat is required; do not guess ids.',
|
|
63
63
|
},
|
|
64
|
+
createIfMissing: { type: 'boolean', description: 'Set false to reuse only an existing room for this acting agent and participant. A missing room is refused without creating a replacement.' },
|
|
64
65
|
newChat: {
|
|
65
66
|
type: 'boolean',
|
|
66
67
|
description: 'Open a separate chat even though one is already open with this participant. ' +
|
|
@@ -81,6 +82,7 @@ export const openConversationCapability = {
|
|
|
81
82
|
throw new Error('participantId is required');
|
|
82
83
|
const { chatId, reused } = await openConversation(args['participantId'], fullCreds(env), {
|
|
83
84
|
newChat: args['newChat'] === true,
|
|
85
|
+
...(typeof args.createIfMissing === 'boolean' ? { createIfMissing: args.createIfMissing } : {}),
|
|
84
86
|
...(typeof args['agreementId'] === 'string' && args['agreementId']
|
|
85
87
|
? { agreementId: args['agreementId'] }
|
|
86
88
|
: {}),
|
|
@@ -99,6 +101,7 @@ export const openConversationCapability = {
|
|
|
99
101
|
: 'Conversation is open (or reused).';
|
|
100
102
|
return {
|
|
101
103
|
chatId,
|
|
104
|
+
actingAgentId: fullCreds(env).agentId,
|
|
102
105
|
...(typeof reused === 'boolean' ? { reused } : {}),
|
|
103
106
|
note: `${outcomeNote} ${grantNote}`,
|
|
104
107
|
};
|
|
@@ -22,5 +22,6 @@ export declare const contextDiscoverGrantableCapability: CapabilityDefinition;
|
|
|
22
22
|
export declare const contextDelegateCapability: CapabilityDefinition;
|
|
23
23
|
export declare const openCapability: CapabilityDefinition;
|
|
24
24
|
export declare const accessExplainCapability: CapabilityDefinition;
|
|
25
|
-
export declare const CONTEXT_CAPABILITIES: CapabilityDefinition[];
|
|
26
25
|
export declare const contextRequestCapability: CapabilityDefinition;
|
|
26
|
+
export declare const accessRequestCapability: CapabilityDefinition;
|
|
27
|
+
export declare const CONTEXT_CAPABILITIES: CapabilityDefinition[];
|
|
@@ -160,8 +160,8 @@ export const contextDiscoverGrantableCapability = {
|
|
|
160
160
|
names: { sdk: 'context_discover_grantable', mcp: 'ziggs_context_discover_grantable' },
|
|
161
161
|
title: 'Find context you cannot read yet',
|
|
162
162
|
descriptions: {
|
|
163
|
-
sdk: 'See what context EXISTS in orgs you actively work in that you CANNOT read yet — the inverse of grant_list. Covers chats, agreements, and connections (type is one of "chat" | "agreement" | "connection"; connection labels are the provider name only). Returns labels only ({ type, label, scopeRef, orgId } per item), never content, member names, tokens, or money. Bounded to orgs you hold an active WORK agreement in (hire/service; a link to a peer org does not open that org), and excludes
|
|
164
|
-
mcp: 'See what context EXISTS in orgs you actively work in that you CANNOT read yet — so you can ask for it instead of failing blind. Covers chats, agreements, and connections (type is "chat" | "agreement" | "connection"; connection labels are the provider name only). Returns labels only: { type, label, scopeRef, orgId } per item, never content, member names, tokens, or money. Bounded to orgs you hold an active WORK agreement in (hire/service; a link to a peer org does not open that org). To act on
|
|
163
|
+
sdk: 'See what context EXISTS in orgs you actively work in that you CANNOT read yet — the inverse of grant_list. Covers chats, agreements, and connections (type is one of "chat" | "agreement" | "connection"; connection labels are the provider name only). Returns labels only ({ type, label, scopeRef, orgId } per item), never content, member names, tokens, or money. Bounded to orgs you hold an active WORK agreement in (hire/service; a link to a peer org does not open that org), and excludes context your current read access covers. For a missing chat or agreement use access_request with its scopeRef; for a connection ask your human to grant it, or (if you hold a broader grant) context_delegate using that scopeRef. Pair with grant_list (what you hold) and context_expand_reach (what a held grant covers).',
|
|
164
|
+
mcp: 'See what context EXISTS in orgs you actively work in that you CANNOT read yet — so you can ask for it instead of failing blind. Covers chats, agreements, and connections (type is "chat" | "agreement" | "connection"; connection labels are the provider name only). Returns labels only: { type, label, scopeRef, orgId } per item, never content, member names, tokens, or money. Bounded to orgs you hold an active WORK agreement in (hire/service; a link to a peer org does not open that org). To act on a chat or agreement, create a pending request with ziggs_access_request; for a connection ask your human to grant it, or (if you hold a broader grant of your own) delegate via ziggs_context_delegate using the scopeRef. Use ziggs_grant_list for what you already hold; this is what you lack.',
|
|
165
165
|
},
|
|
166
166
|
annotation: 'read-only',
|
|
167
167
|
params: {},
|
|
@@ -169,7 +169,9 @@ export const contextDiscoverGrantableCapability = {
|
|
|
169
169
|
handler: async (_args, env) => {
|
|
170
170
|
const creds = fullCreds(env);
|
|
171
171
|
const items = await new ContextDiscoveryClient(creds.operatorKey, creds.agentId).discoverGrantable();
|
|
172
|
-
return { count: items.length, items
|
|
172
|
+
return { count: items.length, items: items.map((item) => ({ ...item,
|
|
173
|
+
actions: item.type === 'connection' ? [] : [requestAccessAction({ scopeKind: item.type, scopeId: item.scopeRef.id }, env)],
|
|
174
|
+
})) };
|
|
173
175
|
},
|
|
174
176
|
};
|
|
175
177
|
export const contextDelegateCapability = {
|
|
@@ -289,15 +291,25 @@ function openBodyFromArgs(args) {
|
|
|
289
291
|
return body;
|
|
290
292
|
}
|
|
291
293
|
function presentOpenResult(result, env) {
|
|
292
|
-
//
|
|
293
|
-
|
|
294
|
-
const requestTool = env.surface === 'mcp' ? 'ziggs_context_request' : 'context_request';
|
|
294
|
+
// Expose a request-only next action, never execute it as part of a read.
|
|
295
|
+
const requestTool = env.surface === 'mcp' ? 'ziggs_access_request' : 'access_request';
|
|
295
296
|
const chatTool = env.surface === 'mcp' ? 'ziggs_chat_open' : 'chat_open';
|
|
297
|
+
const resumeActions = (result.outcome === 'ok' && result.ref.kind === 'agreement'
|
|
298
|
+
? result.page?.items ?? [] : []).flatMap((item) => {
|
|
299
|
+
if (!item || typeof item !== 'object')
|
|
300
|
+
return [];
|
|
301
|
+
const row = item;
|
|
302
|
+
const ask = row.grantRequest;
|
|
303
|
+
if (row.status !== 'active' || ask?.primitive !== 'context' || ask.kind !== 'access-request' || ask.holderId !== fullCreds(env).agentId || !ask.scope?.id || !['artifact', 'chat', 'agreement', 'task'].includes(ask.scope.kind ?? ''))
|
|
304
|
+
return [];
|
|
305
|
+
return [{ kind: 'resume', tool: env.surface === 'mcp' ? 'ziggs_open' : 'open', args: { [`${ask.scope.kind}Id`]: ask.scope.id }, effect: 'read_only', note: 'Approval recorded. Open the original scope; the server rechecks expiry and revocation.' }];
|
|
306
|
+
});
|
|
296
307
|
return {
|
|
297
308
|
...result,
|
|
298
|
-
actions: [],
|
|
309
|
+
actions: result.access.continuation?.request ? [requestAccessAction(result.access.continuation.request, env)] : result.ref.kind === 'artifact' && result.outcome === 'unreadable' ? [requestAccessAction({ scopeKind: 'artifact', scopeId: result.ref.id, permission: 'read', durationHours: 24 }, env)] : resumeActions,
|
|
310
|
+
actingAgentId: fullCreds(env).agentId,
|
|
299
311
|
...(result.ref.kind === 'artifact' && result.outcome !== 'ok' ? {
|
|
300
|
-
requestAccessHint: `If a source you already read supplied this artifact reference and its human owner, ${requestTool} can ask that owner for temporary read access without a prior grant. It needs a conversation with the owner; ${chatTool} can open or reuse one, subject to authorization. Discover the request tool's schema before calling it. This response does not confirm existence or ownership. A request grants no access until the human owner approves.`,
|
|
312
|
+
requestAccessHint: `If a source you already read supplied this artifact reference and its human owner, ${requestTool} scopeKind=artifact can ask that owner for temporary read access without a prior grant. It needs a conversation with the owner; ${chatTool} can open or reuse one, subject to authorization. Discover the request tool's schema before calling it. This response does not confirm existence or ownership. A request grants no access until the human owner approves.`,
|
|
301
313
|
} : {}),
|
|
302
314
|
};
|
|
303
315
|
}
|
|
@@ -342,14 +354,6 @@ export const accessExplainCapability = {
|
|
|
342
354
|
return presentOpenResult(result, env);
|
|
343
355
|
},
|
|
344
356
|
};
|
|
345
|
-
export const CONTEXT_CAPABILITIES = [
|
|
346
|
-
contextReadCapability,
|
|
347
|
-
openCapability,
|
|
348
|
-
accessExplainCapability,
|
|
349
|
-
contextDelegateCapability,
|
|
350
|
-
contextExpandReachCapability,
|
|
351
|
-
contextDiscoverGrantableCapability,
|
|
352
|
-
];
|
|
353
357
|
export const contextRequestCapability = {
|
|
354
358
|
key: 'context_request',
|
|
355
359
|
names: { sdk: 'context_request', mcp: 'ziggs_context_request' },
|
|
@@ -381,3 +385,73 @@ export const contextRequestCapability = {
|
|
|
381
385
|
return { ...result, outcome: 'pending', state: 'requested', appUrl: `${(env.webUrl ?? 'https://ziggsai.com').replace(/\/$/, '')}/app/agreements/${encodeURIComponent(result.agreementId)}`, note: 'Waiting for the artifact owner. No access granted yet; open the original artifact only after approval.' };
|
|
382
386
|
},
|
|
383
387
|
};
|
|
388
|
+
/** A suggested request still needs a purpose; it is never a grant or an approval. */
|
|
389
|
+
function requestAccessAction(args, env) {
|
|
390
|
+
return {
|
|
391
|
+
kind: 'request_access',
|
|
392
|
+
tool: env.surface === 'mcp' ? 'ziggs_access_request' : 'access_request',
|
|
393
|
+
args, requiredInput: args.scopeKind === 'artifact' ? ['reason', 'chatId', 'ownerId'] : ['reason'], effect: 'request_only',
|
|
394
|
+
requiresApproval: true,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
export const accessRequestCapability = {
|
|
398
|
+
key: 'access_request',
|
|
399
|
+
names: { sdk: 'access_request', mcp: 'ziggs_access_request' },
|
|
400
|
+
title: 'Request access for yourself',
|
|
401
|
+
descriptions: {
|
|
402
|
+
sdk: 'Create a pending approval agreement for the calling agent to access one artifact, chat, agreement context, or task branch for 1–168 hours. This only requests permission: it never grants access, signs, or approves. After the authorized person approves, open the original resource. Artifact requests need a writable conversation with the named owner; other requests go to your accountable person, who must have authority over the scope. Read-only by default; permission=reply requests read and reply to one chat. No spending or work commitment. Reuse idempotencyKey for a retry.',
|
|
403
|
+
mcp: 'Ask for missing access through a pending approval agreement. Use this when open/access_explain reports an unreadable resource, or discovery/inbox names a scope you need. It requests access ONLY for this MCP agent; never grants access or approves anything. Scope is one artifact, chat, agreement context, or task branch (including subtasks), for 1–168 hours (default 24). Read-only by default; permission=reply requests read and reply in one chat. For earlier chat messages explicitly set temporal=from-start. Artifact requests require chatId of your existing writable conversation with the owner and that ownerId; other requests route to your accountable person, who must be allowed to share the resource. Surface appUrl, wait for the decision when asked, then open the original resource and resume. Pending grants no access. Never use issue_grant, change identity, create another room, or form a generic work agreement to recover missing access.',
|
|
404
|
+
},
|
|
405
|
+
annotation: 'write', needsAgentId: true,
|
|
406
|
+
params: {
|
|
407
|
+
scopeKind: { type: 'string', required: true, enum: ['artifact', 'chat', 'agreement', 'task'] },
|
|
408
|
+
scopeId: { type: 'string', required: true, description: 'Original returned resource id; this request does not open a new resource' },
|
|
409
|
+
reason: { type: 'string', required: true, description: 'Why access is needed and who will receive the reply or summary' },
|
|
410
|
+
permission: { type: 'string', enum: ['read', 'reply'], description: 'read by default; reply is read and reply and is only valid for a chat' },
|
|
411
|
+
temporal: { type: 'string', enum: ['from-now', 'from-start'], description: 'Chat history requested; default from-now. Earlier messages need from-start. Other resources use from-start.' },
|
|
412
|
+
durationHours: { type: 'number', description: 'Integer 1–168 hours after approval; default 24' },
|
|
413
|
+
chatId: { type: 'string', description: 'Artifact requests only: existing conversation with the owner' },
|
|
414
|
+
ownerId: { type: 'string', description: 'Artifact requests only: human account or participant reference in that conversation' },
|
|
415
|
+
idempotencyKey: { type: 'string', description: 'Reuse for the same logical request' },
|
|
416
|
+
},
|
|
417
|
+
handler: async (args, env) => {
|
|
418
|
+
for (const key of ['scopeKind', 'scopeId', 'reason']) {
|
|
419
|
+
if (typeof args[key] !== 'string' || !String(args[key]).trim())
|
|
420
|
+
throw new Error(`${key} is required`);
|
|
421
|
+
}
|
|
422
|
+
const scopeKind = args.scopeKind;
|
|
423
|
+
if (!['artifact', 'chat', 'agreement', 'task'].includes(scopeKind))
|
|
424
|
+
throw new Error('Unsupported scopeKind');
|
|
425
|
+
const permission = args.permission ?? 'read';
|
|
426
|
+
if (!['read', 'reply'].includes(String(permission)) || (permission === 'reply' && scopeKind !== 'chat'))
|
|
427
|
+
throw new Error('Only chat access may request reply permission');
|
|
428
|
+
if (args.temporal !== undefined && (!['from-now', 'from-start'].includes(String(args.temporal)) || (scopeKind !== 'chat' && args.temporal === 'from-now')))
|
|
429
|
+
throw new Error('Only chats support from-now access');
|
|
430
|
+
const durationHours = args.durationHours ?? 24;
|
|
431
|
+
if (typeof durationHours !== 'number' || !Number.isInteger(durationHours) || durationHours < 1 || durationHours > 168)
|
|
432
|
+
throw new Error('durationHours must be an integer between 1 and 168');
|
|
433
|
+
const creds = fullCreds(env);
|
|
434
|
+
const result = await new ContextGrantsClient(creds.operatorKey, creds.agentId, env.baseUrl).requestAccess({
|
|
435
|
+
scopeKind, scopeId: String(args.scopeId).trim(), reason: String(args.reason).trim(),
|
|
436
|
+
permission: permission, temporal: args.temporal,
|
|
437
|
+
durationHours, chatId: args.chatId, ownerId: args.ownerId,
|
|
438
|
+
}, { idempotencyKey: args.idempotencyKey, laneId: creds.laneId });
|
|
439
|
+
return {
|
|
440
|
+
...result, outcome: 'pending', state: 'requested', actingAgentId: creds.agentId,
|
|
441
|
+
scope: { kind: scopeKind, id: args.scopeId },
|
|
442
|
+
appUrl: `${(env.webUrl ?? 'https://ziggsai.com').replace(/\/$/, '')}/app/agreements/${encodeURIComponent(result.agreementId)}`,
|
|
443
|
+
resumeAfterApproval: { tool: env.surface === 'mcp' ? 'ziggs_open' : 'open', args: { [`${scopeKind}Id`]: args.scopeId } },
|
|
444
|
+
note: 'No access granted. The authorized person must approve; then open the original resource using the same agent identity.',
|
|
445
|
+
};
|
|
446
|
+
},
|
|
447
|
+
};
|
|
448
|
+
export const CONTEXT_CAPABILITIES = [
|
|
449
|
+
contextReadCapability,
|
|
450
|
+
openCapability,
|
|
451
|
+
accessExplainCapability,
|
|
452
|
+
accessRequestCapability,
|
|
453
|
+
contextRequestCapability,
|
|
454
|
+
contextDelegateCapability,
|
|
455
|
+
contextExpandReachCapability,
|
|
456
|
+
contextDiscoverGrantableCapability,
|
|
457
|
+
];
|
|
@@ -11,7 +11,7 @@ export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, presentTa
|
|
|
11
11
|
export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.js';
|
|
12
12
|
export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
|
|
13
13
|
export { GRANTS_CAPABILITIES, listGrantsCapability } from './grants.js';
|
|
14
|
-
export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, contextRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, } from './context.js';
|
|
14
|
+
export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, contextRequestCapability, accessRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, } from './context.js';
|
|
15
15
|
export { CONNECTION_CAPABILITIES, connectionProxyCapability, requestConnectionCapability, } from './connections.js';
|
|
16
16
|
export { DISCOVERY_CAPABILITIES, agentSearchCapability, agentGetCapability, } from './discovery.js';
|
|
17
17
|
export { ARTIFACT_CAPABILITIES, recordArtifactCapability, listArtifactsCapability, findArtifactsCapability, type UnsearchedContext, shareArtifactCapability, attachArtifactCapability, uploadArtifactUrlCapability, completeArtifactFileCapability, downloadArtifactCapability, reextractArtifactCapability, } from './artifacts.js';
|
|
@@ -11,7 +11,7 @@ export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, presentTa
|
|
|
11
11
|
export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.js';
|
|
12
12
|
export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
|
|
13
13
|
export { GRANTS_CAPABILITIES, listGrantsCapability } from './grants.js';
|
|
14
|
-
export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, contextRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, } from './context.js';
|
|
14
|
+
export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, contextRequestCapability, accessRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, } from './context.js';
|
|
15
15
|
export { CONNECTION_CAPABILITIES, connectionProxyCapability, requestConnectionCapability, } from './connections.js';
|
|
16
16
|
export { DISCOVERY_CAPABILITIES, agentSearchCapability, agentGetCapability, } from './discovery.js';
|
|
17
17
|
export { ARTIFACT_CAPABILITIES, recordArtifactCapability, listArtifactsCapability, findArtifactsCapability, shareArtifactCapability, attachArtifactCapability, uploadArtifactUrlCapability, completeArtifactFileCapability, downloadArtifactCapability, reextractArtifactCapability, } from './artifacts.js';
|
|
@@ -13,9 +13,10 @@ import { type Creds } from '../types.js';
|
|
|
13
13
|
* with without a second call.
|
|
14
14
|
*/
|
|
15
15
|
export type ChatSummary = ChatReadDto;
|
|
16
|
-
export declare function openConversation(participantId: string, creds: Creds, { newChat, agreementId }?: {
|
|
16
|
+
export declare function openConversation(participantId: string, creds: Creds, { newChat, agreementId, createIfMissing }?: {
|
|
17
17
|
newChat?: boolean;
|
|
18
18
|
agreementId?: string;
|
|
19
|
+
createIfMissing?: boolean;
|
|
19
20
|
}): Promise<{
|
|
20
21
|
chatId: string;
|
|
21
22
|
reused?: boolean;
|
|
@@ -34,9 +35,8 @@ export interface SendChatMessageInput {
|
|
|
34
35
|
to?: string;
|
|
35
36
|
/**
|
|
36
37
|
* Recipient id. Optional: when omitted, the backend infers the
|
|
37
|
-
* receiver
|
|
38
|
-
*
|
|
39
|
-
* Sent on the wire as `{ id }`; the SDK still takes a string.
|
|
38
|
+
* receiver when Jev is confident. Otherwise it stores room context without
|
|
39
|
+
* a specific wake. Explicit addressing is required for a guaranteed target.
|
|
40
40
|
*/
|
|
41
41
|
receiverId?: string;
|
|
42
42
|
text: string;
|
|
@@ -47,7 +47,6 @@ export interface SendChatMessageInput {
|
|
|
47
47
|
/** Governing service agreement; independent of representation. */
|
|
48
48
|
conversationAgreementId?: string;
|
|
49
49
|
taskId?: string;
|
|
50
|
-
replyToMessageId?: string;
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
52
|
* Where the server says a send landed.
|
|
@@ -122,6 +121,7 @@ export declare class ChatClient {
|
|
|
122
121
|
open(participantId: string, opts?: {
|
|
123
122
|
newChat?: boolean;
|
|
124
123
|
agreementId?: string;
|
|
124
|
+
createIfMissing?: boolean;
|
|
125
125
|
}): Promise<{
|
|
126
126
|
chatId: string;
|
|
127
127
|
reused?: boolean;
|
package/dist/http/ChatClient.js
CHANGED
|
@@ -10,7 +10,7 @@ function assertCreds(creds, op) {
|
|
|
10
10
|
if (!creds?.agentId)
|
|
11
11
|
throw new Error(`agentId is required for ${op}`);
|
|
12
12
|
}
|
|
13
|
-
export async function openConversation(participantId, creds, { newChat = false, agreementId } = {}) {
|
|
13
|
+
export async function openConversation(participantId, creds, { newChat = false, agreementId, createIfMissing } = {}) {
|
|
14
14
|
if (!participantId)
|
|
15
15
|
throw new Error('participantId is required for openConversation');
|
|
16
16
|
assertCreds(creds, 'open conversation');
|
|
@@ -22,6 +22,7 @@ export async function openConversation(participantId, creds, { newChat = false,
|
|
|
22
22
|
body: JSON.stringify({
|
|
23
23
|
participantId,
|
|
24
24
|
...(newChat ? { newChat: true } : {}),
|
|
25
|
+
...(createIfMissing !== undefined ? { createIfMissing } : {}),
|
|
25
26
|
...(agreementId ? { agreementId } : {}),
|
|
26
27
|
}),
|
|
27
28
|
});
|
|
@@ -107,7 +108,6 @@ export async function sendChatMessage(input, creds) {
|
|
|
107
108
|
underAgreementId: input.underAgreementId,
|
|
108
109
|
conversationAgreementId: input.conversationAgreementId,
|
|
109
110
|
taskId: input.taskId,
|
|
110
|
-
replyToMessageId: input.replyToMessageId,
|
|
111
111
|
}),
|
|
112
112
|
});
|
|
113
113
|
if (!res.ok) {
|
|
@@ -96,6 +96,24 @@ export declare class ContextGrantsClient {
|
|
|
96
96
|
*/
|
|
97
97
|
constructor(operatorKey: string, agentId?: string, baseUrl?: string);
|
|
98
98
|
issueGrant(input: IssueContextGrantInput): Promise<GrantView>;
|
|
99
|
+
/** Request-only endpoint: a successful call must still have granted no access. */
|
|
100
|
+
requestAccess(input: {
|
|
101
|
+
scopeKind: 'artifact' | 'chat' | 'agreement' | 'task';
|
|
102
|
+
scopeId: string;
|
|
103
|
+
reason: string;
|
|
104
|
+
permission?: 'read' | 'reply';
|
|
105
|
+
temporal?: 'from-now' | 'from-start';
|
|
106
|
+
durationHours?: number;
|
|
107
|
+
chatId?: string;
|
|
108
|
+
ownerId?: string;
|
|
109
|
+
}, opts?: {
|
|
110
|
+
idempotencyKey?: string;
|
|
111
|
+
laneId?: string;
|
|
112
|
+
}): Promise<{
|
|
113
|
+
status: 'pending_approval';
|
|
114
|
+
agreementId: string;
|
|
115
|
+
accessGranted: false;
|
|
116
|
+
}>;
|
|
99
117
|
requestArtifactAccess(artifactId: string, input: {
|
|
100
118
|
chatId: string;
|
|
101
119
|
ownerId: string;
|
|
@@ -63,6 +63,25 @@ export class ContextGrantsClient {
|
|
|
63
63
|
}
|
|
64
64
|
return parsed.grant;
|
|
65
65
|
}
|
|
66
|
+
/** Request-only endpoint: a successful call must still have granted no access. */
|
|
67
|
+
async requestAccess(input, opts) {
|
|
68
|
+
const res = await fetch(`${this.baseUrl}/context/access/requests`, {
|
|
69
|
+
method: 'POST',
|
|
70
|
+
headers: buildOperatorHeaders(this.operatorKey, this.agentId, {
|
|
71
|
+
'content-type': 'application/json',
|
|
72
|
+
...(opts?.idempotencyKey ? { 'Idempotency-Key': opts.idempotencyKey } : {}),
|
|
73
|
+
}, opts?.laneId),
|
|
74
|
+
body: JSON.stringify(input),
|
|
75
|
+
});
|
|
76
|
+
const body = await res.text().catch(() => '');
|
|
77
|
+
if (!res.ok)
|
|
78
|
+
throwApiError(res, body, `requestAccess failed: ${res.status}`);
|
|
79
|
+
const result = JSON.parse(body);
|
|
80
|
+
if (result.status !== 'pending_approval' || !result.agreementId || result.accessGranted !== false) {
|
|
81
|
+
throw new Error('Expected a pending access request with accessGranted=false');
|
|
82
|
+
}
|
|
83
|
+
return { status: 'pending_approval', agreementId: result.agreementId, accessGranted: false };
|
|
84
|
+
}
|
|
66
85
|
async requestArtifactAccess(artifactId, input, opts) {
|
|
67
86
|
const res = await fetch(`${this.baseUrl}/context/artifacts/${encodeURIComponent(artifactId)}/access-requests`, {
|
|
68
87
|
method: 'POST',
|
|
@@ -32,6 +32,13 @@ export interface ContextOpenAccess {
|
|
|
32
32
|
continuation?: {
|
|
33
33
|
kind: 'owner_decision';
|
|
34
34
|
summary: string;
|
|
35
|
+
request?: {
|
|
36
|
+
scopeKind: 'chat' | 'agreement' | 'task';
|
|
37
|
+
scopeId: string;
|
|
38
|
+
permission: 'read' | 'reply';
|
|
39
|
+
temporal: 'from-now' | 'from-start';
|
|
40
|
+
durationHours: number;
|
|
41
|
+
};
|
|
35
42
|
};
|
|
36
43
|
}
|
|
37
44
|
export interface ContextOpenResult {
|