@ziggs-ai/api-client 0.36.3 → 0.37.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/agreementVerbs.d.ts +3 -11
- package/dist/capabilities/agreementVerbs.js +6 -108
- package/dist/capabilities/context.d.ts +28 -0
- package/dist/capabilities/context.js +26 -0
- package/dist/capabilities/discovery.js +14 -1
- package/dist/capabilities/index.d.ts +2 -2
- package/dist/capabilities/index.js +2 -2
- package/dist/capabilities/marketplace.js +2 -2
- package/dist/capabilities/mcpBriefs.js +0 -12
- package/dist/capabilities/proposeProviderId.d.ts +1 -1
- package/dist/capabilities/proposeProviderId.js +1 -1
- package/dist/http/ContextOpenClient.js +3 -1
- package/dist/http/PaymentsClient.d.ts +0 -5
- package/dist/http/PaymentsClient.js +0 -6
- package/dist/http/operatorHeaders.d.ts +5 -0
- package/dist/http/operatorHeaders.js +13 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/shared/delegateCreds.d.ts +24 -0
- package/dist/shared/delegateCreds.js +44 -0
- package/dist/shared/runtimeLog.js +3 -4
- package/package.json +1 -1
|
@@ -3,20 +3,12 @@ export declare const agreementBuyCapability: CapabilityDefinition;
|
|
|
3
3
|
export declare const agreementBidCapability: CapabilityDefinition;
|
|
4
4
|
export declare const agreementBrokerCapability: CapabilityDefinition;
|
|
5
5
|
export declare const agreementRequestCapability: CapabilityDefinition;
|
|
6
|
-
export declare const agreementOfferCapability: CapabilityDefinition;
|
|
7
|
-
/**
|
|
8
|
-
* Pause and resume act on a listing that already exists and form nothing. A
|
|
9
|
-
* pause keeps the same row, id and sold hires; revoke is the verb that ends a
|
|
10
|
-
* listing for good.
|
|
11
|
-
*/
|
|
12
|
-
export declare const listingPauseCapability: CapabilityDefinition;
|
|
13
|
-
export declare const listingResumeCapability: CapabilityDefinition;
|
|
14
6
|
export declare const agreementHandoffCapability: CapabilityDefinition;
|
|
15
7
|
export declare const AGREEMENT_VERB_CAPABILITIES: CapabilityDefinition[];
|
|
16
8
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
9
|
+
* Pause and resume left the agent surface. A person or the deploy
|
|
10
|
+
* opens and closes a listing. The array stays so registration has one place
|
|
11
|
+
* to look and finds nothing.
|
|
20
12
|
*/
|
|
21
13
|
export declare const LISTING_DOOR_CAPABILITIES: CapabilityDefinition[];
|
|
22
14
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { delegateAgreement, getAgreement, proposeBroadcast, proposeDirectTo, } from '../http/AgreementClient.js';
|
|
2
|
-
import { pauseOffer, publishOffer, resumeOffer } from '../http/MarketplaceClient.js';
|
|
3
2
|
import { fullCreds } from './types.js';
|
|
4
3
|
import { nextCall } from './nextCall.js';
|
|
5
4
|
/**
|
|
@@ -193,7 +192,7 @@ export const agreementBidCapability = {
|
|
|
193
192
|
names: { sdk: 'agreement_bid', mcp: 'ziggs_agreement_bid' },
|
|
194
193
|
title: 'You work, they pay (named counterparty)',
|
|
195
194
|
descriptions: {
|
|
196
|
-
sdk: 'Offer to do work for a named counterparty, who pays. You provide.
|
|
195
|
+
sdk: 'Offer to do work for a named counterparty, who pays. You provide. A standing listing for whoever claims it is published by a person or the deploy, not by this verb.',
|
|
197
196
|
},
|
|
198
197
|
annotation: 'destructive',
|
|
199
198
|
params: {
|
|
@@ -262,7 +261,7 @@ export const agreementRequestCapability = {
|
|
|
262
261
|
names: { sdk: 'agreement_request', mcp: 'ziggs_agreement_request' },
|
|
263
262
|
title: 'They work, you pay (open to anyone)',
|
|
264
263
|
descriptions: {
|
|
265
|
-
sdk: 'Post work you want done and will pay for, for whoever claims it. Whoever claims does the work.
|
|
264
|
+
sdk: 'Post work you want done and will pay for, for whoever claims it. Whoever claims does the work. A standing listing of work you would do is published by a person or the deploy.',
|
|
266
265
|
},
|
|
267
266
|
annotation: 'destructive',
|
|
268
267
|
params: {
|
|
@@ -286,103 +285,6 @@ export const agreementRequestCapability = {
|
|
|
286
285
|
},
|
|
287
286
|
sdkOptions: { isAgreementCreation: true },
|
|
288
287
|
};
|
|
289
|
-
/**
|
|
290
|
-
* No mandate param here, deliberately: a listing is formed inside no job. It is
|
|
291
|
-
* a standing invitation to the world that outlives whatever the agent happens
|
|
292
|
-
* to be doing today, and the publish path says so at its own end
|
|
293
|
-
* (`POST /marketplace/offers/publish`). Hanging one under a job would kill the
|
|
294
|
-
* listing when the job ended.
|
|
295
|
-
*
|
|
296
|
-
* No price default here on purpose: an unstated price is a free hire, and the
|
|
297
|
-
* publish path is the one place that says so. Stating a price publishes a paid
|
|
298
|
-
* listing.
|
|
299
|
-
*
|
|
300
|
-
* No replay key either, and that one has a cost worth knowing: each call
|
|
301
|
-
* publishes a fresh row rather than replaying, and the previous listing is
|
|
302
|
-
* retired as it goes, so an agent that republishes leaves dead rows behind it.
|
|
303
|
-
* One listing per agent still holds; the churn does not.
|
|
304
|
-
*/
|
|
305
|
-
/**
|
|
306
|
-
* Seats on a listing: how many customers may hold a live hire from it at once.
|
|
307
|
-
* A hire that ends gives its seat back, so this is a capacity, not a lifetime
|
|
308
|
-
* count. Only the listing verb takes it; a direct proposal has one customer.
|
|
309
|
-
*/
|
|
310
|
-
const MAX_CLAIMS_PARAM = {
|
|
311
|
-
type: 'number',
|
|
312
|
-
description: 'How many customers may hold a live hire from this listing at once. A hire that ends gives its seat back. While every seat is taken, new claims are refused as full until one frees. Omit for unlimited. Set it when your attention is limited: every customer who hires you can wake you.',
|
|
313
|
-
};
|
|
314
|
-
export const agreementOfferCapability = {
|
|
315
|
-
key: 'agreement_offer',
|
|
316
|
-
names: { sdk: 'agreement_offer', mcp: 'ziggs_agreement_offer' },
|
|
317
|
-
title: 'You work, they pay (open to anyone)',
|
|
318
|
-
descriptions: {
|
|
319
|
-
sdk: 'Publish work you will do, for whoever claims it and pays. You provide. This is your listing: it stands until revoked or exhausted. To offer one named counterparty instead, use agreement_bid.',
|
|
320
|
-
},
|
|
321
|
-
annotation: 'destructive',
|
|
322
|
-
params: { audience: AUDIENCE_PARAM, ...TERMS_PARAMS, maxClaims: MAX_CLAIMS_PARAM },
|
|
323
|
-
needsAgentId: true,
|
|
324
|
-
handler: async (args, env) => {
|
|
325
|
-
const terms = termsFrom(args);
|
|
326
|
-
const agreement = await publishOffer({
|
|
327
|
-
description: terms.description ?? '',
|
|
328
|
-
price: terms.price,
|
|
329
|
-
lifecycle: terms.lifecycle,
|
|
330
|
-
expiresAt: terms.expiresAt,
|
|
331
|
-
maxExecutions: terms.maxExecutions,
|
|
332
|
-
conversationAllowance: terms.conversationAllowance,
|
|
333
|
-
conversationAllowanceScope: terms.conversationAllowanceScope,
|
|
334
|
-
interactionMode: terms.interactionMode,
|
|
335
|
-
billing: terms.billing,
|
|
336
|
-
engagementKind: engagementKindFrom(args),
|
|
337
|
-
audience: args['audience'],
|
|
338
|
-
...(typeof args['maxClaims'] === 'number' ? { maxClaims: args['maxClaims'] } : {}),
|
|
339
|
-
}, fullCreds(env));
|
|
340
|
-
return { agreement, readPlan: publishedNext(env) };
|
|
341
|
-
},
|
|
342
|
-
sdkOptions: { isAgreementCreation: true },
|
|
343
|
-
};
|
|
344
|
-
/* ───────────────────────── the door on your own listing ──────────────────── */
|
|
345
|
-
/** The listing the pause and resume verbs act on. */
|
|
346
|
-
const LISTING_ID_PARAM = {
|
|
347
|
-
type: 'string',
|
|
348
|
-
required: true,
|
|
349
|
-
description: 'Your listing: the agreement id your offer was published under (what ziggs_agreement_offer answered with). On your own profile it is doors.listingAgreementId.',
|
|
350
|
-
};
|
|
351
|
-
/**
|
|
352
|
-
* Pause and resume act on a listing that already exists and form nothing. A
|
|
353
|
-
* pause keeps the same row, id and sold hires; revoke is the verb that ends a
|
|
354
|
-
* listing for good.
|
|
355
|
-
*/
|
|
356
|
-
export const listingPauseCapability = {
|
|
357
|
-
key: 'listing_pause',
|
|
358
|
-
names: { sdk: 'listing_pause', mcp: 'ziggs_listing_pause' },
|
|
359
|
-
title: 'Pause your listing',
|
|
360
|
-
descriptions: {
|
|
361
|
-
sdk: 'Stop taking new customers on a listing you publish, without deleting it. New claims on it are refused until you resume it with listing_resume. Same listing, same id; hires already sold keep running. To end a listing for good, use agreement_revoke.',
|
|
362
|
-
},
|
|
363
|
-
annotation: 'destructive',
|
|
364
|
-
params: { agreementId: LISTING_ID_PARAM },
|
|
365
|
-
needsAgentId: true,
|
|
366
|
-
handler: async (args, env) => {
|
|
367
|
-
const agreement = await pauseOffer(args['agreementId'], fullCreds(env));
|
|
368
|
-
return { status: 'paused', agreement };
|
|
369
|
-
},
|
|
370
|
-
};
|
|
371
|
-
export const listingResumeCapability = {
|
|
372
|
-
key: 'listing_resume',
|
|
373
|
-
names: { sdk: 'listing_resume', mcp: 'ziggs_listing_resume' },
|
|
374
|
-
title: 'Resume your listing',
|
|
375
|
-
descriptions: {
|
|
376
|
-
sdk: 'Reopen a listing you paused with listing_pause: same listing, same id, taking new customers again. A listing closed because every seat is taken, or because its agent stopped answering, reopens on its own and needs no resume.',
|
|
377
|
-
},
|
|
378
|
-
annotation: 'destructive',
|
|
379
|
-
params: { agreementId: LISTING_ID_PARAM },
|
|
380
|
-
needsAgentId: true,
|
|
381
|
-
handler: async (args, env) => {
|
|
382
|
-
const agreement = await resumeOffer(args['agreementId'], fullCreds(env));
|
|
383
|
-
return { status: 'resumed', agreement };
|
|
384
|
-
},
|
|
385
|
-
};
|
|
386
288
|
/* ──────────────────────────────── hand-off ───────────────────────────────── */
|
|
387
289
|
export const agreementHandoffCapability = {
|
|
388
290
|
key: 'agreement_handoff',
|
|
@@ -441,18 +343,14 @@ export const AGREEMENT_VERB_CAPABILITIES = [
|
|
|
441
343
|
agreementBidCapability,
|
|
442
344
|
agreementBrokerCapability,
|
|
443
345
|
agreementRequestCapability,
|
|
444
|
-
agreementOfferCapability,
|
|
445
346
|
agreementHandoffCapability,
|
|
446
347
|
];
|
|
447
348
|
/**
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
349
|
+
* Pause and resume left the agent surface. A person or the deploy
|
|
350
|
+
* opens and closes a listing. The array stays so registration has one place
|
|
351
|
+
* to look and finds nothing.
|
|
451
352
|
*/
|
|
452
|
-
export const LISTING_DOOR_CAPABILITIES = [
|
|
453
|
-
listingPauseCapability,
|
|
454
|
-
listingResumeCapability,
|
|
455
|
-
];
|
|
353
|
+
export const LISTING_DOOR_CAPABILITIES = [];
|
|
456
354
|
/**
|
|
457
355
|
* Subcontract sits next to the propose verbs, not inside them: the parent
|
|
458
356
|
* already exists, and the conversation is optional. The server uses the
|
|
@@ -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',
|
|
@@ -32,6 +33,8 @@ export const agentSearchCapability = {
|
|
|
32
33
|
}
|
|
33
34
|
const chatOpen = env.surface === 'mcp' ? 'ziggs_chat_open' : 'chat_open';
|
|
34
35
|
const linkList = env.surface === 'mcp' ? 'ziggs_link_list' : 'link_list';
|
|
36
|
+
const marketplace = env.surface === 'mcp' ? 'ziggs_marketplace_view' : 'marketplace_view';
|
|
37
|
+
const request = env.surface === 'mcp' ? 'ziggs_agreement_request' : 'agreement_request';
|
|
35
38
|
const people = result.people ?? [];
|
|
36
39
|
const messageThem = people.length
|
|
37
40
|
? {
|
|
@@ -52,6 +55,10 @@ export const agentSearchCapability = {
|
|
|
52
55
|
'your org: people by name (returned under people, to message as people)',
|
|
53
56
|
],
|
|
54
57
|
hint: 'Zero agents means no agent matched these terms; discovery itself is up. ' +
|
|
58
|
+
// An agent given work to farm out stopped here with it undone. The
|
|
59
|
+
// next rungs of the hiring ladder belong at the moment the search
|
|
60
|
+
// comes back empty, not in a skill loaded every session.
|
|
61
|
+
`To get work done, open listings and requests are in ${marketplace}; when nothing fits, post the work with ${request} so whoever can do it claims it. ` +
|
|
55
62
|
"People are not agents: a teammate is found by their name and comes back under people, never as their agents. " +
|
|
56
63
|
`To reach them, open a chat with that user id (${chatOpen} participantId). ` +
|
|
57
64
|
'Matching is lexical, so try shorter or different keywords. ' +
|
|
@@ -83,7 +90,13 @@ export const agentGetCapability = {
|
|
|
83
90
|
const client = new AgentSearchClient(creds.operatorKey, creds.agentId);
|
|
84
91
|
const result = await client.getAgentById(args['agentId']);
|
|
85
92
|
if (!result.success) {
|
|
86
|
-
|
|
93
|
+
// A missing agent and one you may not see answer alike, in the words
|
|
94
|
+
// every read tool uses. There is nothing to request: an agent is reached
|
|
95
|
+
// through its listing or its person, not by access to its profile.
|
|
96
|
+
if (result.error === 'agent not found') {
|
|
97
|
+
throw Object.assign(new Error(RESOURCE_HIDDEN_MESSAGE), { code: 'RESOURCE_HIDDEN' });
|
|
98
|
+
}
|
|
99
|
+
throw new Error(result.error ?? 'Failed to get agent details');
|
|
87
100
|
}
|
|
88
101
|
const { success: _success, ...agent } = result;
|
|
89
102
|
return { agent };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { type CapabilitySurface, type CapabilityAnnotation, type CapabilityParam, type CapabilityEnv, type CapabilityDefinition, fullCreds, rethrowWithContext, } from './types.js';
|
|
2
2
|
export { type McpBrief, type McpDoor, hasMcpBrief, mcpBriefNames, mcpDescription, } from './mcpBriefs.js';
|
|
3
3
|
export { nextCall, nextCallsFromUntrustedContent, isStaleAdvertisedAction, peerPrincipalId, isPersonaFace, workContextFromEnv, type NextCall, type NextCallOutcome, type NextCallEffects, type NextCallHold, type NextCallOptions, type WorkContext, } from './nextCall.js';
|
|
4
|
-
export { AGREEMENT_VERB_CAPABILITIES, LISTING_DOOR_CAPABILITIES,
|
|
4
|
+
export { AGREEMENT_VERB_CAPABILITIES, LISTING_DOOR_CAPABILITIES, agreementBuyCapability, agreementBidCapability, agreementBrokerCapability, agreementRequestCapability, agreementHandoffCapability, agreementSubcontractCapability, } from './agreementVerbs.js';
|
|
5
5
|
export { PAYMENT_CAPABILITIES, paymentBalanceCapability } from './payments.js';
|
|
6
6
|
export { LINK_CAPABILITIES, listLinksCapability, proposeLinkCapability, linkIsReachOnly, } from './links.js';
|
|
7
7
|
export { INTRODUCTION_CAPABILITIES, mintIntroductionCapability, redeemIntroductionCapability, listIntroductionsCapability, revokeIntroductionCapability, } from './introductions.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, 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';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { fullCreds, rethrowWithContext, } from './types.js';
|
|
2
2
|
export { hasMcpBrief, mcpBriefNames, mcpDescription, } from './mcpBriefs.js';
|
|
3
3
|
export { nextCall, nextCallsFromUntrustedContent, isStaleAdvertisedAction, peerPrincipalId, isPersonaFace, workContextFromEnv, } from './nextCall.js';
|
|
4
|
-
export { AGREEMENT_VERB_CAPABILITIES, LISTING_DOOR_CAPABILITIES,
|
|
4
|
+
export { AGREEMENT_VERB_CAPABILITIES, LISTING_DOOR_CAPABILITIES, agreementBuyCapability, agreementBidCapability, agreementBrokerCapability, agreementRequestCapability, agreementHandoffCapability, agreementSubcontractCapability, } from './agreementVerbs.js';
|
|
5
5
|
export { PAYMENT_CAPABILITIES, paymentBalanceCapability } from './payments.js';
|
|
6
6
|
export { LINK_CAPABILITIES, listLinksCapability, proposeLinkCapability, linkIsReachOnly, } from './links.js';
|
|
7
7
|
export { INTRODUCTION_CAPABILITIES, mintIntroductionCapability, redeemIntroductionCapability, listIntroductionsCapability, revokeIntroductionCapability, } from './introductions.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';
|
|
@@ -7,8 +7,8 @@ const VIEW_KINDS = ['all', 'requests', 'offers'];
|
|
|
7
7
|
function publishHint(env) {
|
|
8
8
|
const claim = env.surface === 'mcp' ? 'ziggs_agreement_claim' : 'agreement_claim';
|
|
9
9
|
const publish = env.surface === 'mcp'
|
|
10
|
-
? '
|
|
11
|
-
: '
|
|
10
|
+
? 'Post a request with ziggs_agreement_request (claimer works, you pay). A standing listing is published by a person or the deploy.'
|
|
11
|
+
: 'Post a request via agreement_propose with proposedTo "everyone"/"org" and no providerId. A standing listing is published by a person or the deploy.';
|
|
12
12
|
return (`Reuse an active agreement that already covers the work. Otherwise claim any row with ${claim} ` +
|
|
13
13
|
`(agreementId) — listings are take-it-or-leave-it, never counter one. ${publish}`);
|
|
14
14
|
}
|
|
@@ -62,10 +62,6 @@ const BRIEFS = {
|
|
|
62
62
|
does: 'Posts work you want done and will pay for: whoever claims it does the work.',
|
|
63
63
|
changes: 'publishes a request others can claim',
|
|
64
64
|
},
|
|
65
|
-
ziggs_agreement_offer: {
|
|
66
|
-
does: 'Publishes your listing: you provide, whoever claims it pays. Claimers take it as posted.',
|
|
67
|
-
changes: 'publishes it until revoked or sold out',
|
|
68
|
-
},
|
|
69
65
|
ziggs_agreement_buy: {
|
|
70
66
|
does: 'Proposes work to a named counterparty: they provide, you pay. Most published agents accept only claims of their listing.',
|
|
71
67
|
changes: 'sends a proposal they approve, reject or counter',
|
|
@@ -102,14 +98,6 @@ const BRIEFS = {
|
|
|
102
98
|
does: 'Ends an agreement you provide, for good, once its whole scope is delivered. A finished task closes with ziggs_task_set_result instead.',
|
|
103
99
|
changes: 'revokes every grant it conferred; it cannot be reopened',
|
|
104
100
|
},
|
|
105
|
-
ziggs_listing_pause: {
|
|
106
|
-
does: 'Stops new claims on a listing you publish; hires already sold keep running.',
|
|
107
|
-
changes: 'pauses it until ziggs_listing_resume',
|
|
108
|
-
},
|
|
109
|
-
ziggs_listing_resume: {
|
|
110
|
-
does: 'Reopens a listing you paused.',
|
|
111
|
-
changes: 'it takes new claims again',
|
|
112
|
-
},
|
|
113
101
|
// Rooms
|
|
114
102
|
ziggs_chat_list: {
|
|
115
103
|
does: 'Lists rooms you hold a grant on, with last message and unread count. fields adds members or rosterSummary.',
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* tools. Stated on the schema so a fresh agent does not burn a turn learning
|
|
4
4
|
* the rule from the validation error.
|
|
5
5
|
*/
|
|
6
|
-
export declare const AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION = "REQUIRED on a direct proposal: name who does the work \u2014 your own id (you are offering to work) or the proposedTo id (you are commissioning the recipient). Do not omit it when proposedTo is a person/agent id. Broadcast (proposedTo everyone/org): omit
|
|
6
|
+
export declare const AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION = "REQUIRED on a direct proposal: name who does the work \u2014 your own id (you are offering to work) or the proposedTo id (you are commissioning the recipient). Do not omit it when proposedTo is a person/agent id. Broadcast (proposedTo everyone/org): omit providerId to post a request (claimer works). A person or the deploy publishes a standing listing; this agent does not. Payer is always the non-providing side.";
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* tools. Stated on the schema so a fresh agent does not burn a turn learning
|
|
4
4
|
* the rule from the validation error.
|
|
5
5
|
*/
|
|
6
|
-
export const AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION = 'REQUIRED on a direct proposal: name who does the work — your own id (you are offering to work) or the proposedTo id (you are commissioning the recipient). Do not omit it when proposedTo is a person/agent id. Broadcast (proposedTo everyone/org): omit
|
|
6
|
+
export const AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION = 'REQUIRED on a direct proposal: name who does the work — your own id (you are offering to work) or the proposedTo id (you are commissioning the recipient). Do not omit it when proposedTo is a person/agent id. Broadcast (proposedTo everyone/org): omit providerId to post a request (claimer works). A person or the deploy publishes a standing listing; this agent does not. Payer is always the non-providing side.';
|
|
@@ -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
|
-
|
|
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
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
type AssistantHints = {
|
|
2
2
|
orgId?: string;
|
|
3
3
|
resource?: string;
|
|
4
|
+
clientSessionId?: string;
|
|
5
|
+
instanceId?: string;
|
|
6
|
+
workspaceIds?: string;
|
|
7
|
+
app?: string;
|
|
8
|
+
sessionName?: string;
|
|
4
9
|
};
|
|
5
10
|
/** Node-only, opt-in request context. Ordinary HTTP clients remain browser-safe. */
|
|
6
11
|
export declare function withAssistantRequest<T>(hints: AssistantHints, run: () => T): Promise<Awaited<T>>;
|
|
@@ -6,11 +6,22 @@ export async function withAssistantRequest(hints, run) {
|
|
|
6
6
|
assistantRequest = new AsyncLocalStorage();
|
|
7
7
|
return assistantRequest;
|
|
8
8
|
});
|
|
9
|
-
|
|
9
|
+
const context = await assistantContextLoading;
|
|
10
|
+
// A workspace router adds its per-operation target inside the caller's
|
|
11
|
+
// session. Preserve that session without sharing it between concurrent calls.
|
|
12
|
+
return await context.run({ ...context.getStore(), ...hints, orgId: hints.orgId, resource: hints.resource }, run);
|
|
10
13
|
}
|
|
11
14
|
export function assistantRequestHeaders() {
|
|
12
15
|
const hints = assistantRequest?.getStore();
|
|
13
|
-
return {
|
|
16
|
+
return {
|
|
17
|
+
...(hints?.orgId ? { 'X-Workspace-Id': hints.orgId } : {}),
|
|
18
|
+
...(hints?.resource ? { 'X-Ziggs-Resource': hints.resource } : {}),
|
|
19
|
+
...(hints?.clientSessionId ? { 'X-Ziggs-Session': hints.clientSessionId } : {}),
|
|
20
|
+
...(hints?.instanceId ? { 'X-Ziggs-Instance': hints.instanceId } : {}),
|
|
21
|
+
...(hints?.workspaceIds ? { 'X-Ziggs-Workspaces': hints.workspaceIds } : {}),
|
|
22
|
+
...(hints?.app ? { 'X-Ziggs-App': hints.app } : {}),
|
|
23
|
+
...(hints?.sessionName ? { 'X-Ziggs-Session-Name': hints.sessionName } : {}),
|
|
24
|
+
};
|
|
14
25
|
}
|
|
15
26
|
/**
|
|
16
27
|
* Auth headers for operator-key HTTP clients.
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export { getBackendUrl } from './utils/urlUtils.js';
|
|
|
7
7
|
export { configureApiClient, apiClientConfig } from './config.js';
|
|
8
8
|
export type { ApiClientConfig, ApiClientLogLevel } from './config.js';
|
|
9
9
|
export { runtimeLog, resetRuntimeLogLevelCache } from './shared/runtimeLog.js';
|
|
10
|
+
export type { RuntimeLogLevel } from './shared/runtimeLog.js';
|
|
11
|
+
export { resolveDelegateCreds, resolveDelegateHttpUrl, } from './shared/delegateCreds.js';
|
|
12
|
+
export type { DelegateEnv, ResolvedDelegateCreds, } from './shared/delegateCreds.js';
|
|
10
13
|
export { RateLimitedError, isRateLimited, parseRetryAfterMs, pollSurfaceError, } from './shared/rateLimit.js';
|
|
11
14
|
export { parseErrorMessage, parseErrorCode, throwApiError, } from './shared/apiError.js';
|
|
12
15
|
export { ApiError } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { getBackendUrl } from './utils/urlUtils.js';
|
|
|
6
6
|
// the host injects the environment; this package never reads it.
|
|
7
7
|
export { configureApiClient, apiClientConfig } from './config.js';
|
|
8
8
|
export { runtimeLog, resetRuntimeLogLevelCache } from './shared/runtimeLog.js';
|
|
9
|
+
export { resolveDelegateCreds, resolveDelegateHttpUrl, } from './shared/delegateCreds.js';
|
|
9
10
|
// one ApiError shape; 429s carry the server's wait.
|
|
10
11
|
export { RateLimitedError, isRateLimited, parseRetryAfterMs, pollSurfaceError, } from './shared/rateLimit.js';
|
|
11
12
|
// One reader for the one error shape the API answers in — exported so nothing has
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The environment a delegate process was handed. Callers read the process;
|
|
3
|
+
* this module does not.
|
|
4
|
+
*/
|
|
5
|
+
export interface DelegateEnv {
|
|
6
|
+
ZIGGS_API_URL?: string;
|
|
7
|
+
HTTP_URL?: string;
|
|
8
|
+
ZIGGS_OPERATOR_KEY?: string;
|
|
9
|
+
ZIGGS_AGENT_ID?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ResolvedDelegateCreds {
|
|
12
|
+
/** `ZIGGS_API_URL` wins over `HTTP_URL`. Absent when neither is set. */
|
|
13
|
+
httpUrl?: string;
|
|
14
|
+
operatorKey: string;
|
|
15
|
+
/** Empty when the key is a directory connection (`connectionClientId`). */
|
|
16
|
+
agentId: string;
|
|
17
|
+
}
|
|
18
|
+
/** Which base URL this process was told to use. The specific name wins. */
|
|
19
|
+
export declare function resolveDelegateHttpUrl(env: DelegateEnv): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* One reading of a delegate's key, agent, and base URL.
|
|
22
|
+
* An agent-scoped key supplies the agent id. A session JWT is refused.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveDelegateCreds(env: DelegateEnv): ResolvedDelegateCreds;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { decodeOperatorKeyClaims, isOperatorKeyExpired } from './operatorKey.js';
|
|
2
|
+
const MINT = 'An MCP client that supports OAuth signs in at https://mcp.ziggsai.com/mcp. ' +
|
|
3
|
+
'To run with a key, issue one in the Ziggs app (Agent-only access, or Agents > Access keys). ' +
|
|
4
|
+
'Docs: https://ziggsai.com/docs#connect-assistant';
|
|
5
|
+
/** Which base URL this process was told to use. The specific name wins. */
|
|
6
|
+
export function resolveDelegateHttpUrl(env) {
|
|
7
|
+
const specific = env.ZIGGS_API_URL?.trim();
|
|
8
|
+
if (specific)
|
|
9
|
+
return specific;
|
|
10
|
+
const generic = env.HTTP_URL?.trim();
|
|
11
|
+
return generic || undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One reading of a delegate's key, agent, and base URL.
|
|
15
|
+
* An agent-scoped key supplies the agent id. A session JWT is refused.
|
|
16
|
+
*/
|
|
17
|
+
export function resolveDelegateCreds(env) {
|
|
18
|
+
const operatorKey = env.ZIGGS_OPERATOR_KEY?.trim() ?? '';
|
|
19
|
+
if (!operatorKey) {
|
|
20
|
+
throw new Error(`ZIGGS_OPERATOR_KEY is required. ${MINT}`);
|
|
21
|
+
}
|
|
22
|
+
const claims = decodeOperatorKeyClaims(operatorKey);
|
|
23
|
+
if (claims?.type && claims.type !== 'operator') {
|
|
24
|
+
throw new Error(`ZIGGS_OPERATOR_KEY must be an operator token (not a session JWT). ${MINT}`);
|
|
25
|
+
}
|
|
26
|
+
if (isOperatorKeyExpired(claims)) {
|
|
27
|
+
throw new Error(`operator key expired (keyId=${claims?.keyId ?? 'unknown'}). ${MINT}`);
|
|
28
|
+
}
|
|
29
|
+
const httpUrl = resolveDelegateHttpUrl(env);
|
|
30
|
+
if (claims?.connectionClientId) {
|
|
31
|
+
return { httpUrl, operatorKey, agentId: '' };
|
|
32
|
+
}
|
|
33
|
+
const bound = claims?.boundAgentId?.trim() || '';
|
|
34
|
+
const fromEnv = env.ZIGGS_AGENT_ID?.trim() || '';
|
|
35
|
+
if (bound && fromEnv && bound !== fromEnv) {
|
|
36
|
+
throw new Error(`ZIGGS_AGENT_ID (${fromEnv}) conflicts with agent-scoped key bound to "${bound}". ` +
|
|
37
|
+
'Remove ZIGGS_AGENT_ID or use a fleet impersonation key instead.');
|
|
38
|
+
}
|
|
39
|
+
const agentId = bound || fromEnv;
|
|
40
|
+
if (!agentId) {
|
|
41
|
+
throw new Error(`set ZIGGS_AGENT_ID, or mint an agent-scoped operator key (boundAgentId in token). ${MINT}`);
|
|
42
|
+
}
|
|
43
|
+
return { httpUrl, operatorKey, agentId };
|
|
44
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @see agent-sdk/src/shared/runtimeLog.ts
|
|
2
|
+
* Process-wide log level for every package that imports this. The host sets it
|
|
3
|
+
* with `configureApiClient({ logLevel })`; this package does not read the
|
|
4
|
+
* environment. The SDK re-exports these names.
|
|
6
5
|
*/
|
|
7
6
|
import { apiClientConfig, apiClientConfigVersion } from '../config.js';
|
|
8
7
|
const SEVERITY = {
|