@ziggs-ai/api-client 0.9.9 → 0.9.11
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/README.md +1 -1
- package/dist/ConnectionManager.d.ts +1 -1
- package/dist/ConnectionManager.js +1 -1
- package/dist/capabilities/agreements.d.ts +1 -1
- package/dist/capabilities/agreements.js +1 -1
- package/dist/capabilities/artifacts.d.ts +3 -3
- package/dist/capabilities/artifacts.js +8 -8
- package/dist/capabilities/chat.d.ts +4 -4
- package/dist/capabilities/chat.js +5 -5
- package/dist/capabilities/context.d.ts +4 -4
- package/dist/capabilities/context.js +6 -6
- package/dist/capabilities/discovery.js +1 -1
- package/dist/capabilities/grants.d.ts +3 -3
- package/dist/capabilities/grants.js +3 -3
- package/dist/capabilities/links.js +1 -1
- package/dist/capabilities/marketplace.d.ts +1 -1
- package/dist/capabilities/marketplace.js +1 -1
- package/dist/capabilities/payments.js +1 -1
- package/dist/capabilities/proposeProviderId.d.ts +1 -1
- package/dist/capabilities/proposeProviderId.js +1 -1
- package/dist/capabilities/types.d.ts +3 -3
- package/dist/capabilities/types.js +2 -2
- package/dist/http/AgentSearchClient.d.ts +1 -2
- package/dist/http/AgreementClient.d.ts +11 -21
- package/dist/http/AgreementClient.js +29 -59
- package/dist/http/ArtifactsClient.d.ts +9 -9
- package/dist/http/ArtifactsClient.js +10 -10
- package/dist/http/ChatClient.d.ts +3 -3
- package/dist/http/ChatClient.js +6 -6
- package/dist/http/ConnectionsClient.d.ts +8 -8
- package/dist/http/ConnectionsClient.js +7 -7
- package/dist/http/ContextDiscoveryClient.d.ts +1 -1
- package/dist/http/ContextGrantsClient.d.ts +7 -7
- package/dist/http/ContextGrantsClient.js +3 -3
- package/dist/http/ContextReadClient.d.ts +3 -3
- package/dist/http/ContextReadClient.js +4 -4
- package/dist/http/GrantsClient.d.ts +4 -4
- package/dist/http/GrantsClient.js +1 -1
- package/dist/http/InboxClient.d.ts +9 -5
- package/dist/http/InboxClient.js +13 -6
- package/dist/http/MarketplaceClient.js +3 -3
- package/dist/http/OrgsClient.d.ts +10 -10
- package/dist/http/OrgsClient.js +11 -11
- package/dist/http/PaymentsClient.d.ts +4 -4
- package/dist/http/PaymentsClient.js +7 -7
- package/dist/http/TaskClient.d.ts +6 -6
- package/dist/http/TaskClient.js +3 -3
- package/dist/http/agreementFlows.d.ts +3 -3
- package/dist/http/agreementFlows.js +2 -2
- package/dist/http/grants.d.ts +1 -1
- package/dist/http/grants.js +1 -1
- package/dist/http/index.js +1 -1
- package/dist/http/operatorHeaders.d.ts +2 -2
- package/dist/http/operatorHeaders.js +2 -2
- package/dist/index.js +2 -2
- package/dist/shared/apiError.d.ts +1 -1
- package/dist/shared/apiError.js +1 -1
- package/dist/shared/rateLimit.d.ts +2 -2
- package/dist/shared/rateLimit.js +2 -2
- package/dist/types.d.ts +30 -28
- package/dist/types.js +4 -4
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GrantView } from './grants.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* added `artifact` — the narrowest context scope: one specific artifact,
|
|
4
4
|
* shared without sharing any chat or agreement it sits in. Still the context
|
|
5
5
|
* rail, not a new grant primitive.
|
|
6
6
|
*/
|
|
@@ -11,7 +11,7 @@ export interface ContextGrantScope {
|
|
|
11
11
|
id: string;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated
|
|
14
|
+
* @deprecated context grants now serialise to the canonical
|
|
15
15
|
* {@link GrantView} like every other rail. This alias previously declared a
|
|
16
16
|
* flat `scopeKind`/`scopeId` + `revoked` shape that the backend never actually
|
|
17
17
|
* emitted (it sends nested `scope: { kind, id }` and folds temporal/watermark
|
|
@@ -43,13 +43,13 @@ export type DelegateContextGrantResult = {
|
|
|
43
43
|
agreementId: string;
|
|
44
44
|
ownerId?: string;
|
|
45
45
|
};
|
|
46
|
-
/** A single readable entry inside a grant's scope — id + label only
|
|
46
|
+
/** A single readable entry inside a grant's scope — id + label only. */
|
|
47
47
|
export interface ReachEntry {
|
|
48
48
|
id: string;
|
|
49
49
|
label: string;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* reach expansion — the chat/agreement ids a grant you hold actually
|
|
53
53
|
* covers, so an org/agreement-scoped grant becomes a concrete list you can
|
|
54
54
|
* `context_read` through (via=chat:<id> / agreement:<id>). Ids + labels only,
|
|
55
55
|
* never content. Org scope is capped; `truncatedChats`/`truncatedAgreements`
|
|
@@ -64,7 +64,7 @@ export interface GrantReachResult {
|
|
|
64
64
|
truncatedAgreements: number;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* context grant management — list / issue / delegate / revoke.
|
|
68
68
|
*/
|
|
69
69
|
export declare class ContextGrantsClient {
|
|
70
70
|
private readonly operatorKey;
|
|
@@ -78,14 +78,14 @@ export declare class ContextGrantsClient {
|
|
|
78
78
|
issueGrant(input: IssueContextGrantInput): Promise<GrantView>;
|
|
79
79
|
delegateGrant(parentGrantId: string, input: DelegateContextGrantInput): Promise<DelegateContextGrantResult>;
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* expand a grant you hold into the chat/agreement ids inside its
|
|
82
82
|
* scope. A grant is a fence, not a listing: discovery says "you hold
|
|
83
83
|
* org:acme", this says which chats/agreements that covers. Holder-only,
|
|
84
84
|
* labels-only, grant-fenced server-side.
|
|
85
85
|
*/
|
|
86
86
|
getReach(grantId: string): Promise<GrantReachResult>;
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* share an artifact THIS agent authored with another agent.
|
|
89
89
|
*
|
|
90
90
|
* Not a delegation: an agent holds no grant over its own output, so there is
|
|
91
91
|
* no parent to attenuate. Authorship is the authority, held by the agent's
|
|
@@ -2,7 +2,7 @@ import { getBackendUrl } from '../utils/urlUtils.js';
|
|
|
2
2
|
import { buildOperatorHeaders } from './operatorHeaders.js';
|
|
3
3
|
import { throwApiError } from '../shared/apiError.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* context grant management — list / issue / delegate / revoke.
|
|
6
6
|
*/
|
|
7
7
|
export class ContextGrantsClient {
|
|
8
8
|
operatorKey;
|
|
@@ -71,7 +71,7 @@ export class ContextGrantsClient {
|
|
|
71
71
|
return { status: 'granted', grant: parsed.grant };
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* expand a grant you hold into the chat/agreement ids inside its
|
|
75
75
|
* scope. A grant is a fence, not a listing: discovery says "you hold
|
|
76
76
|
* org:acme", this says which chats/agreements that covers. Holder-only,
|
|
77
77
|
* labels-only, grant-fenced server-side.
|
|
@@ -96,7 +96,7 @@ export class ContextGrantsClient {
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
99
|
+
* share an artifact THIS agent authored with another agent.
|
|
100
100
|
*
|
|
101
101
|
* Not a delegation: an agent holds no grant over its own output, so there is
|
|
102
102
|
* no parent to attenuate. Authorship is the authority, held by the agent's
|
|
@@ -42,7 +42,7 @@ export interface ContextReadEnvelope<T = unknown> {
|
|
|
42
42
|
nextCursor: string | null;
|
|
43
43
|
latestSequence?: string | null;
|
|
44
44
|
}
|
|
45
|
-
/** Aggregated chat snapshot from `GET /context/snapshot` (
|
|
45
|
+
/** Aggregated chat snapshot from `GET /context/snapshot` (follow-up). */
|
|
46
46
|
export interface ContextSnapshotResult {
|
|
47
47
|
history: unknown[];
|
|
48
48
|
agreements: unknown[];
|
|
@@ -59,7 +59,7 @@ export interface ContextSnapshotResult {
|
|
|
59
59
|
chatMissing?: boolean;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* Protocol-first uniform context reads
|
|
62
|
+
* Protocol-first uniform context reads.
|
|
63
63
|
* Wraps `GET /context/read/:type` — one client, one envelope, four types.
|
|
64
64
|
*/
|
|
65
65
|
export declare class ContextReadClient {
|
|
@@ -70,7 +70,7 @@ export declare class ContextReadClient {
|
|
|
70
70
|
/**
|
|
71
71
|
* @param operatorKey Agent-scoped or fleet operator key.
|
|
72
72
|
* @param agentId Required for fleet keys (sent as X-Agent-Id). Omit for agent-scoped keys.
|
|
73
|
-
* @param laneId
|
|
73
|
+
* @param laneId the wake's lane, sent as X-Ziggs-Lane. This is the
|
|
74
74
|
* path the dogfood leak ran through: `via=artifact:<other customer's spec>`
|
|
75
75
|
* was authorised purely because the same agent had authored it.
|
|
76
76
|
*/
|
|
@@ -49,7 +49,7 @@ export function parseVia(via) {
|
|
|
49
49
|
: null;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
* Protocol-first uniform context reads
|
|
52
|
+
* Protocol-first uniform context reads.
|
|
53
53
|
* Wraps `GET /context/read/:type` — one client, one envelope, four types.
|
|
54
54
|
*/
|
|
55
55
|
export class ContextReadClient {
|
|
@@ -60,7 +60,7 @@ export class ContextReadClient {
|
|
|
60
60
|
/**
|
|
61
61
|
* @param operatorKey Agent-scoped or fleet operator key.
|
|
62
62
|
* @param agentId Required for fleet keys (sent as X-Agent-Id). Omit for agent-scoped keys.
|
|
63
|
-
* @param laneId
|
|
63
|
+
* @param laneId the wake's lane, sent as X-Ziggs-Lane. This is the
|
|
64
64
|
* path the dogfood leak ran through: `via=artifact:<other customer's spec>`
|
|
65
65
|
* was authorised purely because the same agent had authored it.
|
|
66
66
|
*/
|
|
@@ -106,7 +106,7 @@ export class ContextReadClient {
|
|
|
106
106
|
if (!res.ok) {
|
|
107
107
|
// A 403 here is a legitimate outcome, not a transport failure: addressing
|
|
108
108
|
// and authorisation are separate, so an agent can be told about mail it
|
|
109
|
-
// is not (or is no longer) allowed to open.
|
|
109
|
+
// is not (or is no longer) allowed to open. one ApiError shape
|
|
110
110
|
// (429 → RateLimitedError with Retry-After).
|
|
111
111
|
throw pollSurfaceError(`ContextReadClient.read ${type}`, res, body);
|
|
112
112
|
}
|
|
@@ -143,7 +143,7 @@ export class ContextReadClient {
|
|
|
143
143
|
const res = await fetch(url.toString(), { headers });
|
|
144
144
|
const body = await res.text().catch(() => '');
|
|
145
145
|
if (!res.ok) {
|
|
146
|
-
//
|
|
146
|
+
// ApiError for every non-OK (429 → RateLimitedError).
|
|
147
147
|
throw pollSurfaceError('ContextReadClient.snapshot', res, body);
|
|
148
148
|
}
|
|
149
149
|
return JSON.parse(body);
|
|
@@ -16,7 +16,7 @@ export interface ListGrantsQuery {
|
|
|
16
16
|
scopeId?: string;
|
|
17
17
|
/**
|
|
18
18
|
* `'holder'` (default) = grants you hold. `'issuer'` = grants you caused
|
|
19
|
-
* (
|
|
19
|
+
* (for agents: author-shares + delegate children).
|
|
20
20
|
*/
|
|
21
21
|
role?: 'holder' | 'issuer';
|
|
22
22
|
/** Filter to grants of one health. */
|
|
@@ -25,7 +25,7 @@ export interface ListGrantsQuery {
|
|
|
25
25
|
limit?: number;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* a grant rail the caller's operator key cannot read, named
|
|
29
29
|
* by the backend on `GET /grants` (it silently drops those rails from `items`,
|
|
30
30
|
* so the unified list tool names what it isn't entitled to instead of
|
|
31
31
|
* presenting a short list as if it were complete). Replaces the client-side
|
|
@@ -41,12 +41,12 @@ export interface ListGrantsResult {
|
|
|
41
41
|
hasMore: boolean;
|
|
42
42
|
/**
|
|
43
43
|
* Rails the caller can't read, per the backend. Absent when the backend
|
|
44
|
-
* predates
|
|
44
|
+
* predates or every requested rail was readable.
|
|
45
45
|
*/
|
|
46
46
|
unreadableRails?: UnreadableRail[];
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* unified grant listing across every rail. `GET /grants` returns the
|
|
50
50
|
* canonical GrantView for each grant the caller holds (or, admin-gated, a named
|
|
51
51
|
* holder), filterable by scope kind and health, with cursor pagination. Replaces
|
|
52
52
|
* the old per-rail listers (context discovery, connection-grants,
|
|
@@ -2,7 +2,7 @@ import { getBackendUrl } from '../utils/urlUtils.js';
|
|
|
2
2
|
import { throwApiError } from '../shared/apiError.js';
|
|
3
3
|
import { buildOperatorHeaders } from './operatorHeaders.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* unified grant listing across every rail. `GET /grants` returns the
|
|
6
6
|
* canonical GrantView for each grant the caller holds (or, admin-gated, a named
|
|
7
7
|
* holder), filterable by scope kind and health, with cursor pagination. Replaces
|
|
8
8
|
* the old per-rail listers (context discovery, connection-grants,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { InboxAckResult, InboxEnvelope, InboxReadOptions } from '../types.js';
|
|
2
2
|
/**
|
|
3
|
-
* The doorbell, not the door
|
|
3
|
+
* The doorbell, not the door: references addressed to this agent
|
|
4
4
|
* since its last ack — never content. Flow: inbox → read → act → ack
|
|
5
|
-
|
|
5
|
+
*. Wraps `GET /inbox` and `POST /inbox/ack`.
|
|
6
6
|
*/
|
|
7
7
|
export declare class InboxClient {
|
|
8
8
|
private readonly operatorKey;
|
|
@@ -17,9 +17,13 @@ export declare class InboxClient {
|
|
|
17
17
|
private inboxUrl;
|
|
18
18
|
getInbox(opts?: InboxReadOptions): Promise<InboxEnvelope>;
|
|
19
19
|
/**
|
|
20
|
-
* Advance this agent's watermark — pass the envelope's `ackTo
|
|
20
|
+
* Advance this agent's watermark — pass the envelope's `ackTo` plus every
|
|
21
|
+
* `resourceId` handled in `(priorAck, upTo]` (ZIG-1305). Monotonic
|
|
21
22
|
* server-side: an older value is a no-op, so a replayed ack can never
|
|
22
|
-
* redeliver handled work.
|
|
23
|
+
* redeliver handled work. An ack that would bury unlisted deliveries is
|
|
24
|
+
* refused.
|
|
23
25
|
*/
|
|
24
|
-
ack(upTo: string
|
|
26
|
+
ack(upTo: string, opts?: {
|
|
27
|
+
handledResourceIds?: string[];
|
|
28
|
+
}): Promise<InboxAckResult>;
|
|
25
29
|
}
|
package/dist/http/InboxClient.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getBackendUrl } from '../utils/urlUtils.js';
|
|
2
2
|
import { pollSurfaceError } from '../shared/rateLimit.js';
|
|
3
3
|
/**
|
|
4
|
-
* The doorbell, not the door
|
|
4
|
+
* The doorbell, not the door: references addressed to this agent
|
|
5
5
|
* since its last ack — never content. Flow: inbox → read → act → ack
|
|
6
|
-
|
|
6
|
+
*. Wraps `GET /inbox` and `POST /inbox/ack`.
|
|
7
7
|
*/
|
|
8
8
|
export class InboxClient {
|
|
9
9
|
operatorKey;
|
|
@@ -47,17 +47,24 @@ export class InboxClient {
|
|
|
47
47
|
return JSON.parse(body);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Advance this agent's watermark — pass the envelope's `ackTo
|
|
50
|
+
* Advance this agent's watermark — pass the envelope's `ackTo` plus every
|
|
51
|
+
* `resourceId` handled in `(priorAck, upTo]` (ZIG-1305). Monotonic
|
|
51
52
|
* server-side: an older value is a no-op, so a replayed ack can never
|
|
52
|
-
* redeliver handled work.
|
|
53
|
+
* redeliver handled work. An ack that would bury unlisted deliveries is
|
|
54
|
+
* refused.
|
|
53
55
|
*/
|
|
54
|
-
async ack(upTo) {
|
|
56
|
+
async ack(upTo, opts = {}) {
|
|
55
57
|
if (!upTo)
|
|
56
58
|
throw new Error('InboxClient.ack: upTo is required');
|
|
57
59
|
const res = await fetch(`${this.baseUrl}/inbox/ack`, {
|
|
58
60
|
method: 'POST',
|
|
59
61
|
headers: this.headers(),
|
|
60
|
-
body: JSON.stringify({
|
|
62
|
+
body: JSON.stringify({
|
|
63
|
+
upTo,
|
|
64
|
+
...(opts.handledResourceIds
|
|
65
|
+
? { handledResourceIds: opts.handledResourceIds }
|
|
66
|
+
: {}),
|
|
67
|
+
}),
|
|
61
68
|
});
|
|
62
69
|
const body = await res.text().catch(() => '');
|
|
63
70
|
if (!res.ok) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// one shaping rule for every agreement this package parses.
|
|
2
2
|
import { shapeAgreement } from './AgreementClient.js';
|
|
3
3
|
import { getBackendUrl } from '../utils/urlUtils.js';
|
|
4
4
|
import { throwApiError } from '../shared/apiError.js';
|
|
@@ -8,7 +8,7 @@ function buildHeaders(creds) {
|
|
|
8
8
|
'content-type': 'application/json',
|
|
9
9
|
Authorization: `Bearer ${creds.operatorKey}`,
|
|
10
10
|
'X-Agent-Id': creds.agentId,
|
|
11
|
-
//
|
|
11
|
+
// the wake's lane, so the backend can fence this call to the
|
|
12
12
|
// engagement it belongs to rather than the agent's whole authority.
|
|
13
13
|
...(creds.laneId ? { 'X-Ziggs-Lane': creds.laneId } : {}),
|
|
14
14
|
};
|
|
@@ -114,7 +114,7 @@ export class MarketplaceClient {
|
|
|
114
114
|
constructor(operatorKey, agentId) {
|
|
115
115
|
if (!operatorKey)
|
|
116
116
|
throw new Error('MarketplaceClient: operatorKey is required');
|
|
117
|
-
// agentId may be absent for agent-scoped keys
|
|
117
|
+
// agentId may be absent for agent-scoped keys; the Creds-based
|
|
118
118
|
// standalone functions still assert it per call.
|
|
119
119
|
this.creds = { operatorKey, agentId };
|
|
120
120
|
}
|
|
@@ -6,10 +6,10 @@ export interface MyOrg {
|
|
|
6
6
|
role?: string;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* the operator's full org membership (not just granted
|
|
10
10
|
* scopes, which is all the grant listers see). Lets a delegate resolve an org
|
|
11
|
-
* name to an id and offer a pick-list instead of demanding a pasted org_
|
|
12
|
-
* Moved here from ziggs-mcp so every surface rides the one client
|
|
11
|
+
* name to an id and offer a pick-list instead of demanding a pasted org_.. id.
|
|
12
|
+
* Moved here from ziggs-mcp so every surface rides the one client.
|
|
13
13
|
*/
|
|
14
14
|
export declare function fetchMyOrgs(creds: Creds, baseUrl?: string): Promise<MyOrg[]>;
|
|
15
15
|
export type OrgResolution = {
|
|
@@ -22,26 +22,26 @@ export type OrgResolution = {
|
|
|
22
22
|
status: 'not-found';
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* resolve an org selector (exact org_.. id OR a name/handle) against
|
|
26
26
|
* the operator's memberships. Exact id wins; otherwise case-insensitive name
|
|
27
27
|
* match. Ambiguous names return the candidates rather than guessing.
|
|
28
28
|
*/
|
|
29
29
|
export declare function resolveOrgSelector(orgs: MyOrg[], selector: string): OrgResolution;
|
|
30
|
-
/** MCP OAuth auto-provisioned delegate id prefix
|
|
30
|
+
/** MCP OAuth auto-provisioned delegate id prefix. */
|
|
31
31
|
export declare const MCP_OAUTH_DELEGATE_AGENT_ID_PREFIX = "claude-delegate--";
|
|
32
32
|
/** True when `agentId` is an inbound MCP OAuth auto-provisioned delegate. */
|
|
33
33
|
export declare function isMcpOAuthDelegateAgentId(agentId: string): boolean;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* runtime acting org from the server (self-hire / agent
|
|
36
36
|
* row): GET /agents/claude-delegate/access. Moved here from ziggs-mcp's inline
|
|
37
|
-
* fetch (
|
|
37
|
+
* fetch ( "one client for every surface").
|
|
38
38
|
*
|
|
39
39
|
* Only valid for MCP OAuth Claude-delegate sessions. Hosted / fleet
|
|
40
|
-
* impersonation must use {@link fetchHostedAgentAccess}
|
|
40
|
+
* impersonation must use {@link fetchHostedAgentAccess}.
|
|
41
41
|
*/
|
|
42
42
|
export declare function fetchDelegateAccess(creds: Creds, baseUrl?: string): Promise<Record<string, unknown>>;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* session access for hosted / fleet impersonation (owner key +
|
|
45
45
|
* X-Agent-Id, or an agent-scoped key that is not a Claude OAuth delegate).
|
|
46
46
|
*
|
|
47
47
|
* `GET /agents/claude-delegate/access` refuses those credentials (or reports
|
|
@@ -50,7 +50,7 @@ export declare function fetchDelegateAccess(creds: Creds, baseUrl?: string): Pro
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function fetchHostedAgentAccess(creds: Creds, baseUrl?: string): Promise<Record<string, unknown>>;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* pick the access reader that matches the acting agent.
|
|
54
54
|
* Claude OAuth delegates → self-hire status; everything else → hosted path.
|
|
55
55
|
*/
|
|
56
56
|
export declare function fetchSessionAccess(creds: Creds, baseUrl?: string): Promise<Record<string, unknown>>;
|
package/dist/http/OrgsClient.js
CHANGED
|
@@ -2,10 +2,10 @@ import { getBackendUrl } from '../utils/urlUtils.js';
|
|
|
2
2
|
import { throwApiError } from '../shared/apiError.js';
|
|
3
3
|
import { buildOperatorHeaders } from './operatorHeaders.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* the operator's full org membership (not just granted
|
|
6
6
|
* scopes, which is all the grant listers see). Lets a delegate resolve an org
|
|
7
|
-
* name to an id and offer a pick-list instead of demanding a pasted org_
|
|
8
|
-
* Moved here from ziggs-mcp so every surface rides the one client
|
|
7
|
+
* name to an id and offer a pick-list instead of demanding a pasted org_.. id.
|
|
8
|
+
* Moved here from ziggs-mcp so every surface rides the one client.
|
|
9
9
|
*/
|
|
10
10
|
export async function fetchMyOrgs(creds, baseUrl) {
|
|
11
11
|
const url = `${baseUrl || getBackendUrl()}/orgs/me`;
|
|
@@ -26,7 +26,7 @@ export async function fetchMyOrgs(creds, baseUrl) {
|
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* resolve an org selector (exact org_.. id OR a name/handle) against
|
|
30
30
|
* the operator's memberships. Exact id wins; otherwise case-insensitive name
|
|
31
31
|
* match. Ambiguous names return the candidates rather than guessing.
|
|
32
32
|
*/
|
|
@@ -42,19 +42,19 @@ export function resolveOrgSelector(orgs, selector) {
|
|
|
42
42
|
return { status: 'ambiguous', matches: byName };
|
|
43
43
|
return { status: 'not-found' };
|
|
44
44
|
}
|
|
45
|
-
/** MCP OAuth auto-provisioned delegate id prefix
|
|
45
|
+
/** MCP OAuth auto-provisioned delegate id prefix. */
|
|
46
46
|
export const MCP_OAUTH_DELEGATE_AGENT_ID_PREFIX = 'claude-delegate--';
|
|
47
47
|
/** True when `agentId` is an inbound MCP OAuth auto-provisioned delegate. */
|
|
48
48
|
export function isMcpOAuthDelegateAgentId(agentId) {
|
|
49
49
|
return !!agentId && agentId.startsWith(MCP_OAUTH_DELEGATE_AGENT_ID_PREFIX);
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* runtime acting org from the server (self-hire / agent
|
|
53
53
|
* row): GET /agents/claude-delegate/access. Moved here from ziggs-mcp's inline
|
|
54
|
-
* fetch (
|
|
54
|
+
* fetch ( "one client for every surface").
|
|
55
55
|
*
|
|
56
56
|
* Only valid for MCP OAuth Claude-delegate sessions. Hosted / fleet
|
|
57
|
-
* impersonation must use {@link fetchHostedAgentAccess}
|
|
57
|
+
* impersonation must use {@link fetchHostedAgentAccess}.
|
|
58
58
|
*/
|
|
59
59
|
export async function fetchDelegateAccess(creds, baseUrl) {
|
|
60
60
|
const url = `${baseUrl || getBackendUrl()}/agents/claude-delegate/access`;
|
|
@@ -69,7 +69,7 @@ export async function fetchDelegateAccess(creds, baseUrl) {
|
|
|
69
69
|
return body ? JSON.parse(body) : {};
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* session access for hosted / fleet impersonation (owner key +
|
|
73
73
|
* X-Agent-Id, or an agent-scoped key that is not a Claude OAuth delegate).
|
|
74
74
|
*
|
|
75
75
|
* `GET /agents/claude-delegate/access` refuses those credentials (or reports
|
|
@@ -93,7 +93,7 @@ export async function fetchHostedAgentAccess(creds, baseUrl) {
|
|
|
93
93
|
? parsed.activeOrgId
|
|
94
94
|
: null;
|
|
95
95
|
const match = (parsed.orgs ?? []).find((o) => o.orgId === activeOrgId);
|
|
96
|
-
// Prefer `activeOrg`
|
|
96
|
+
// Prefer `activeOrg` — membership list often omits the agent home
|
|
97
97
|
// org under fleet impersonation.
|
|
98
98
|
const fromActive = parsed.activeOrg;
|
|
99
99
|
const orgName = (typeof fromActive?.name === 'string' && fromActive.name) ||
|
|
@@ -111,7 +111,7 @@ export async function fetchHostedAgentAccess(creds, baseUrl) {
|
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* pick the access reader that matches the acting agent.
|
|
115
115
|
* Claude OAuth delegates → self-hire status; everything else → hosted path.
|
|
116
116
|
*/
|
|
117
117
|
export async function fetchSessionAccess(creds, baseUrl) {
|
|
@@ -76,12 +76,12 @@ export type WaitForApprovalResult = {
|
|
|
76
76
|
approval: PaymentApproval;
|
|
77
77
|
};
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
79
|
+
* the one payments client for every surface (agent-sdk, ziggs-mcp,
|
|
80
80
|
* scripts). Consolidates the former agent-sdk private ZiggsPayClient. Wallet
|
|
81
81
|
* ops ride the operator key; agent-impersonated calls send X-Agent-Id and are
|
|
82
82
|
* policy-gated server-side (transfers above threshold return
|
|
83
83
|
* `approval_required`). Wallet-rail grant mutations (issue / attenuate /
|
|
84
|
-
* revoke) live here; grant *listing* is the unified GET /grants
|
|
84
|
+
* revoke) live here; grant *listing* is the unified GET /grants.
|
|
85
85
|
*/
|
|
86
86
|
export declare class PaymentsClient {
|
|
87
87
|
private readonly operatorKey;
|
|
@@ -106,7 +106,7 @@ export declare class PaymentsClient {
|
|
|
106
106
|
description?: string;
|
|
107
107
|
paymentGrantId?: string;
|
|
108
108
|
}): Promise<HoldResult>;
|
|
109
|
-
/** Prefer a single active wallet grant the agent already holds
|
|
109
|
+
/** Prefer a single active wallet grant the agent already holds. */
|
|
110
110
|
private resolveAgentPaymentGrantId;
|
|
111
111
|
release({ holdId, action, toWalletId, idempotencyKey, }: {
|
|
112
112
|
holdId: string;
|
|
@@ -131,7 +131,7 @@ export declare class PaymentsClient {
|
|
|
131
131
|
revokeGrant(grantId: string): Promise<RevokeGrantResult>;
|
|
132
132
|
/**
|
|
133
133
|
* Live wallet grants the acting agent holds, via the unified GET /grants
|
|
134
|
-
* (
|
|
134
|
+
* (retired GET /payments/grants), following the cursor to completion.
|
|
135
135
|
*/
|
|
136
136
|
listGrants(): Promise<GrantView[]>;
|
|
137
137
|
createTopUpIntent({ amount, description, currency, }?: {
|
|
@@ -6,12 +6,12 @@ function randomIdempotencyKey(prefix = 'op') {
|
|
|
6
6
|
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* the one payments client for every surface (agent-sdk, ziggs-mcp,
|
|
10
10
|
* scripts). Consolidates the former agent-sdk private ZiggsPayClient. Wallet
|
|
11
11
|
* ops ride the operator key; agent-impersonated calls send X-Agent-Id and are
|
|
12
12
|
* policy-gated server-side (transfers above threshold return
|
|
13
13
|
* `approval_required`). Wallet-rail grant mutations (issue / attenuate /
|
|
14
|
-
* revoke) live here; grant *listing* is the unified GET /grants
|
|
14
|
+
* revoke) live here; grant *listing* is the unified GET /grants.
|
|
15
15
|
*/
|
|
16
16
|
export class PaymentsClient {
|
|
17
17
|
operatorKey;
|
|
@@ -50,7 +50,7 @@ export class PaymentsClient {
|
|
|
50
50
|
throw new Error('transfer: `to` is required');
|
|
51
51
|
if (!(Number.isInteger(amount) && amount > 0))
|
|
52
52
|
throw new Error('transfer: `amount` must be a positive integer (cents)');
|
|
53
|
-
//
|
|
53
|
+
// resolve a standing/active grant when the caller omitted one
|
|
54
54
|
// (Claude/MCP ensureForUser mints it). Explicit id still wins.
|
|
55
55
|
if (this.agentId && !paymentGrantId) {
|
|
56
56
|
paymentGrantId = (await this.resolveAgentPaymentGrantId()) ?? undefined;
|
|
@@ -93,7 +93,7 @@ export class PaymentsClient {
|
|
|
93
93
|
async hold({ amount, idempotencyKey, description, paymentGrantId, }) {
|
|
94
94
|
if (!(Number.isInteger(amount) && amount > 0))
|
|
95
95
|
throw new Error('hold: `amount` must be a positive integer (cents)');
|
|
96
|
-
//
|
|
96
|
+
// agent holds reserve the owner's wallet; require a grant.
|
|
97
97
|
if (this.agentId && !paymentGrantId) {
|
|
98
98
|
paymentGrantId = (await this.resolveAgentPaymentGrantId()) ?? undefined;
|
|
99
99
|
}
|
|
@@ -106,7 +106,7 @@ export class PaymentsClient {
|
|
|
106
106
|
paymentGrantId,
|
|
107
107
|
}));
|
|
108
108
|
}
|
|
109
|
-
/** Prefer a single active wallet grant the agent already holds
|
|
109
|
+
/** Prefer a single active wallet grant the agent already holds. */
|
|
110
110
|
async resolveAgentPaymentGrantId() {
|
|
111
111
|
try {
|
|
112
112
|
const grants = await this.listGrants();
|
|
@@ -148,7 +148,7 @@ export class PaymentsClient {
|
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
150
|
* Live wallet grants the acting agent holds, via the unified GET /grants
|
|
151
|
-
* (
|
|
151
|
+
* (retired GET /payments/grants), following the cursor to completion.
|
|
152
152
|
*/
|
|
153
153
|
async listGrants() {
|
|
154
154
|
const grants = new GrantsClient(this.operatorKey, this.agentId, this.baseUrl);
|
|
@@ -239,7 +239,7 @@ export class PaymentsClient {
|
|
|
239
239
|
const response = await fetch(`${this.baseUrl}${path}`, init);
|
|
240
240
|
const text = await response.text();
|
|
241
241
|
if (!response.ok) {
|
|
242
|
-
//
|
|
242
|
+
// ApiError; PaymentsError remains the duck type for `.status`.
|
|
243
243
|
throwApiError(response, text, `HTTP ${response.status}`);
|
|
244
244
|
}
|
|
245
245
|
return text ? JSON.parse(text) : null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Creds, type Task, type TaskState } from '../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* When the buyer reviews a task's plan. Task-rail only — an agreement has no
|
|
4
|
-
* plan to review, which is why
|
|
4
|
+
* plan to review, which is why cut this from the propose/counter/
|
|
5
5
|
* subcontract inputs rather than teaching those routes to keep one.
|
|
6
6
|
*/
|
|
7
7
|
export type PlanReviewTiming = 'with_proposal' | 'before_execution';
|
|
@@ -13,9 +13,9 @@ export interface CreateTaskData {
|
|
|
13
13
|
planReviewTiming?: PlanReviewTiming;
|
|
14
14
|
requireMidWorkPlanAck?: boolean;
|
|
15
15
|
idempotencyKey?: string;
|
|
16
|
-
/** Explicit delegation target
|
|
16
|
+
/** Explicit delegation target — must be a party to the agreement; validated server-side. */
|
|
17
17
|
assigneeId?: string;
|
|
18
|
-
/**
|
|
18
|
+
/** prior-step artifact handles consumed as structured input links. */
|
|
19
19
|
inputArtifactIds?: string[];
|
|
20
20
|
}
|
|
21
21
|
export declare function createTask(taskData: CreateTaskData, creds: Creds): Promise<Task>;
|
|
@@ -38,10 +38,10 @@ export declare function getActiveTasksForChat(chatId: string, creds: Creds): Pro
|
|
|
38
38
|
export declare function cancelTask(taskId: string, creds: Creds): Promise<Task>;
|
|
39
39
|
export declare function getSubtasks(parentTaskId: string, creds: Creds): Promise<Task[]>;
|
|
40
40
|
export interface PlanReplaceStep {
|
|
41
|
-
/** Omit to let the server mint `step-<n
|
|
41
|
+
/** Omit to let the server mint `step-<n>`. */
|
|
42
42
|
stepId?: string;
|
|
43
43
|
description: string;
|
|
44
|
-
/** Omit to use the array index
|
|
44
|
+
/** Omit to use the array index. */
|
|
45
45
|
order?: number;
|
|
46
46
|
/**
|
|
47
47
|
* ZIG-1313: step progress. Omit for `pending`. Send `completed` /
|
|
@@ -60,7 +60,7 @@ export interface ListTasksOptions {
|
|
|
60
60
|
state?: string;
|
|
61
61
|
cursor?: string;
|
|
62
62
|
limit?: number;
|
|
63
|
-
/** Filter to tasks assigned to this id
|
|
63
|
+
/** Filter to tasks assigned to this id. */
|
|
64
64
|
assignedTo?: string;
|
|
65
65
|
}
|
|
66
66
|
export interface ListTasksResult {
|
package/dist/http/TaskClient.js
CHANGED
|
@@ -6,7 +6,7 @@ function buildHeaders(creds) {
|
|
|
6
6
|
'content-type': 'application/json',
|
|
7
7
|
Authorization: `Bearer ${creds.operatorKey}`,
|
|
8
8
|
'X-Agent-Id': creds.agentId,
|
|
9
|
-
//
|
|
9
|
+
// the wake's lane, so the backend can fence this call to the
|
|
10
10
|
// engagement it belongs to rather than the agent's whole authority.
|
|
11
11
|
...(creds.laneId ? { 'X-Ziggs-Lane': creds.laneId } : {}),
|
|
12
12
|
};
|
|
@@ -108,7 +108,7 @@ export async function getActiveTasksForAgent(agentId, creds) {
|
|
|
108
108
|
const fromAgent = Array.isArray(data?.['tasks']) ? data['tasks'] : [];
|
|
109
109
|
if (fromAgent.length > 0)
|
|
110
110
|
return fromAgent;
|
|
111
|
-
// Fallback when /agents/:id/tasks is empty but party-agreement tasks exist
|
|
111
|
+
// Fallback when /agents/:id/tasks is empty but party-agreement tasks exist.
|
|
112
112
|
return getActiveTasksForAgentViaPartyAgreements(agentId, creds);
|
|
113
113
|
}
|
|
114
114
|
async function getActiveTasksForAgentViaPartyAgreements(agentId, creds) {
|
|
@@ -352,7 +352,7 @@ export class TaskClient {
|
|
|
352
352
|
constructor(operatorKey, agentId) {
|
|
353
353
|
if (!operatorKey)
|
|
354
354
|
throw new Error('TaskClient: operatorKey is required');
|
|
355
|
-
// agentId may be absent for agent-scoped keys
|
|
355
|
+
// agentId may be absent for agent-scoped keys; the Creds-based
|
|
356
356
|
// standalone functions still assert it per call.
|
|
357
357
|
this.creds = { operatorKey, agentId };
|
|
358
358
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ClaimedKind, type ProposeTerms } from './AgreementClient.js';
|
|
2
2
|
import { type Agreement, type Creds, type EngagementKind } from '../types.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* one propose grammar. Direct, broadcast (quest and standing
|
|
5
5
|
* offer), and link proposals all flow through here; the surfaces expose a
|
|
6
6
|
* single propose tool instead of dedicated publish/request tools.
|
|
7
7
|
*
|
|
@@ -23,14 +23,14 @@ export declare function proposeUnified(input: UnifiedProposeInput, creds: Creds)
|
|
|
23
23
|
shape: ProposeShape;
|
|
24
24
|
}>;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* one claim verb for any open broadcast: link invite, quest,
|
|
27
27
|
* hand-off, or standing offer.
|
|
28
28
|
*
|
|
29
29
|
* One request. This used to read the agreement first to decide which endpoint to
|
|
30
30
|
* post to, and `GET /agreements/:id` is party-scoped — a claimer is by definition
|
|
31
31
|
* not yet a party to the broadcast it is claiming, so the routing read 404'd and
|
|
32
32
|
* every standing offer in the store failed with "Agreement not found" before
|
|
33
|
-
* either claim endpoint was called
|
|
33
|
+
* either claim endpoint was called. The backend routes it now, where
|
|
34
34
|
* the row is readable without being a party to it.
|
|
35
35
|
*
|
|
36
36
|
* `kind` arrives on the claim response — the route that did the routing reports
|
|
@@ -56,14 +56,14 @@ export async function proposeUnified(input, creds) {
|
|
|
56
56
|
return { agreement, shape: 'direct' };
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* one claim verb for any open broadcast: link invite, quest,
|
|
60
60
|
* hand-off, or standing offer.
|
|
61
61
|
*
|
|
62
62
|
* One request. This used to read the agreement first to decide which endpoint to
|
|
63
63
|
* post to, and `GET /agreements/:id` is party-scoped — a claimer is by definition
|
|
64
64
|
* not yet a party to the broadcast it is claiming, so the routing read 404'd and
|
|
65
65
|
* every standing offer in the store failed with "Agreement not found" before
|
|
66
|
-
* either claim endpoint was called
|
|
66
|
+
* either claim endpoint was called. The backend routes it now, where
|
|
67
67
|
* the row is readable without being a party to it.
|
|
68
68
|
*
|
|
69
69
|
* `kind` arrives on the claim response — the route that did the routing reports
|
package/dist/http/grants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* the one grant shape the backend presents on the wire, mirrored for
|
|
3
3
|
* SDK consumers. Context, connection, and payment grants all serialise to this
|
|
4
4
|
* exact object (see backend `src/grants/grant-view.ts`), so a caller reads one
|
|
5
5
|
* shape to answer "what grants exist, and are they live?" regardless of rail.
|
package/dist/http/grants.js
CHANGED