@ziggs-ai/api-client 0.42.19 → 0.42.20

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.42.20
6
+
7
+ - `access_request` takes its `scopeKind` list from `@ziggs-ai/contracts` `ACCESS_REQUEST_SCOPE_KINDS`, and passes `connectionTools` (a connection) and `spendingMaxAmount` (a wallet, hundredths of a point) through.
8
+
5
9
  ## 0.42.19
6
10
 
7
11
  - Taking a grant back uses `DELETE /grants/:grantId`.
@@ -6,6 +6,7 @@ import { ContextOpenClient } from '../http/ContextOpenClient.js';
6
6
  import { ContextGrantsClient, } from '../http/ContextGrantsClient.js';
7
7
  import { ContextDiscoveryClient } from '../http/ContextDiscoveryClient.js';
8
8
  import { grantCaveat, CONTEXT_GRANT_SCOPE_KINDS, } from '../http/grants.js';
9
+ import { ACCESS_REQUEST_SCOPE_KINDS, } from '@ziggs-ai/contracts';
9
10
  import { fetchMyOrgs, resolveOrgSelector } from '../http/OrgsClient.js';
10
11
  import { fullCreds } from './types.js';
11
12
  // What an agent may give or pass on through these tools. The context rail
@@ -433,14 +434,14 @@ export const accessRequestCapability = {
433
434
  title: 'Request access for yourself or named readers',
434
435
  annotation: 'destructive', needsAgentId: true,
435
436
  descriptions: {
436
- sdk: 'Request optional bounded access to one message, artifact, agreement context or task, or ask to send messages to a destination (scopeKind=contact). Creates only a pending approval; never grants access or approves. Choose recipientId when several approvers are offered; with one, it is selected automatically: your work brief offers them for this wake — workBrief.actingFor.customer.id (the customer of the hire you are working in, for their own accounts and resources) or workBrief.actingFor.operator.id (your operator, for tools you bring). Anyone else is refused, and the refusal lists who you can ask. Artifact requests go to the selected approver inbox; no conversation is needed. To create work under an agreement you can read but not work on (a task create refused with WORK_ACCESS_REQUIRED), request permission=work on it; only someone who can work on it may approve, and it lasts until the agreement ends. To work on one task only, request permission=work with scopeKind=task: a yes makes you its assignee. Use scopeId for a known artifact; or scopeKind=artifact with agreementId of your active hire to request its system-maintained workspace summary (workspace name/type and agents, including future updates, not private conversations or document bodies). Send the returned appUrl, wait for human approval, then follow the returned resume action. To arrange reading of one artifact for others, name them in holders (agents by id, people or workspaces by their authorized principal IDs); include yourself only if you need to read it too. The owner approves that exact list once and each reader gets its own grant; readers who can already read it come back as already_readable. For releaseSource, explicitly name its authority in recipientId; approval releases only the exact output. Hiring alone grants no source access. Revocation and expiry are checked by the system.',
437
+ sdk: 'Request optional bounded access to one message, artifact, agreement context or task, or ask to send messages to a destination (scopeKind=contact), to use a connection (scopeKind=connection, name connectionTools), to spend from a wallet (scopeKind=wallet, name spendingMaxAmount in hundredths of a point: 500 is ϟ5.00), or to change a page (scopeKind=thread). Creates only a pending approval; never grants access or approves. Choose recipientId when several approvers are offered; with one, it is selected automatically: your work brief offers them for this wake — workBrief.actingFor.customer.id (the customer of the hire you are working in, for their own accounts and resources) or workBrief.actingFor.operator.id (your operator, for tools you bring). Anyone else is refused, and the refusal lists who you can ask. Artifact requests go to the selected approver inbox; no conversation is needed. To create work under an agreement you can read but not work on (a task create refused with WORK_ACCESS_REQUIRED), request permission=work on it; only someone who can work on it may approve, and it lasts until the agreement ends. To work on one task only, request permission=work with scopeKind=task: a yes makes you its assignee. Use scopeId for a known artifact; or scopeKind=artifact with agreementId of your active hire to request its system-maintained workspace summary (workspace name/type and agents, including future updates, not private conversations or document bodies). Send the returned appUrl, wait for human approval, then follow the returned resume action. To arrange reading of one artifact for others, name them in holders (agents by id, people or workspaces by their authorized principal IDs); include yourself only if you need to read it too. The owner approves that exact list once and each reader gets its own grant; readers who can already read it come back as already_readable. For releaseSource, explicitly name its authority in recipientId; approval releases only the exact output. Hiring alone grants no source access. Revocation and expiry are checked by the system.',
437
438
  },
438
439
  params: {
439
- scopeKind: { type: 'string', required: true, enum: ['message', 'artifact', 'agreement', 'task', 'contact'], description: 'contact: ask to send messages to scopeId (a person, an agent or a workspace inbox). One-way; it reads nothing and gives no reply path.' },
440
+ scopeKind: { type: 'string', required: true, enum: [...ACCESS_REQUEST_SCOPE_KINDS], description: 'contact: send to scopeId. connection: use of a connection (connectionTools). wallet: spend (spendingMaxAmount). thread: post a new page version.' },
440
441
  scopeId: { type: 'string', description: 'Original resource id. Omit when using a hire agreementId to request its workspace summary.' },
441
442
  agreementId: { type: 'string', description: 'Artifact scope only: current hire id, used instead of scopeId to request the system-maintained workspace summary.' },
442
443
  reason: { type: 'string', required: true, description: 'Why access is needed and who will receive the reply or summary' },
443
- permission: { type: 'string', enum: ['read', 'work'], description: 'read by default. work: agreement work, or with scopeKind=task, that task.' },
444
+ permission: { type: 'string', enum: ['read', 'work', 'change'], description: 'read by default. work: agreement work, or with scopeKind=task, that task. change: a page (scopeKind=thread).' },
444
445
  temporal: { type: 'string', enum: ['from-start'], description: 'Retained resource access uses from-start; owner policy remains authoritative.' },
445
446
  durationHours: { type: 'number', description: 'Integer 1–168 hours after approval; reads default to 24' },
446
447
  // Not required here: the server requires it, and a request without it
@@ -466,6 +467,15 @@ export const accessRequestCapability = {
466
467
  },
467
468
  },
468
469
  idempotencyKey: { type: 'string', description: 'Reuse for the same logical request' },
470
+ connectionTools: {
471
+ type: 'array',
472
+ description: 'Connection only: MCP tool names to request. The person can approve a subset.',
473
+ items: { type: 'string' },
474
+ },
475
+ spendingMaxAmount: {
476
+ type: 'number',
477
+ description: 'Wallet only: most this grant may spend, in hundredths of a point (500 is ϟ5.00). The person can approve a lower amount.',
478
+ },
469
479
  },
470
480
  handler: async (args, env) => {
471
481
  // recipientId is resolved by the server: it picks the sole eligible recipient
@@ -474,16 +484,14 @@ export const accessRequestCapability = {
474
484
  if (typeof args[key] !== 'string' || !String(args[key]).trim())
475
485
  throw new Error(`${key} is required`);
476
486
  }
477
- const scopeKind = args.scopeKind;
478
- if (!['message', 'artifact', 'agreement', 'task', 'contact'].includes(scopeKind))
479
- throw new Error('Unsupported scopeKind');
487
+ const scopeKind = String(args.scopeKind).trim();
480
488
  const contact = scopeKind === 'contact';
481
489
  const agreementId = typeof args.agreementId === 'string' ? args.agreementId.trim() : undefined;
482
490
  const scopeId = typeof args.scopeId === 'string' ? args.scopeId.trim() : undefined;
483
491
  if (Boolean(agreementId) === Boolean(scopeId) || (agreementId && scopeKind !== 'artifact'))
484
492
  throw new Error('Provide scopeId, or agreementId for its workspace summary artifact');
485
493
  const permission = args.permission ?? 'read';
486
- if (!['read', 'work'].includes(String(permission)))
494
+ if (!['read', 'work', 'change'].includes(String(permission)))
487
495
  throw new Error('permission must be read or work');
488
496
  // Which scope takes which permission is the server's answer, with its reason.
489
497
  if (args.temporal !== undefined && args.temporal !== 'from-start')
@@ -513,6 +521,8 @@ export const accessRequestCapability = {
513
521
  releaseSource = { kind: source.kind, id: source.id.trim() };
514
522
  }
515
523
  const creds = fullCreds(env);
524
+ const connectionTools = Array.isArray(args.connectionTools) ? args.connectionTools : undefined;
525
+ const spendingMaxAmount = typeof args.spendingMaxAmount === 'number' ? args.spendingMaxAmount : undefined;
516
526
  const result = await new ContextGrantsClient(creds.operatorKey, creds.agentId, env.baseUrl).requestAccess({
517
527
  scopeKind, scopeId, agreementId, reason: String(args.reason).trim(),
518
528
  // A contact request carries no permission unless the caller named one;
@@ -523,6 +533,8 @@ export const accessRequestCapability = {
523
533
  ...(holders ? { holders } : {}),
524
534
  ...(contributionTo ? { contributionTo } : {}),
525
535
  ...(releaseSource ? { releaseSource } : {}),
536
+ ...(connectionTools ? { connectionTools } : {}),
537
+ ...(spendingMaxAmount !== undefined ? { spendingMaxAmount } : {}),
526
538
  }, { idempotencyKey: args.idempotencyKey, laneId: creds.laneId });
527
539
  const actingAgentId = result.actingAgentId ?? (creds.agentId || undefined);
528
540
  if (result.status === 'already_readable') {
@@ -148,7 +148,7 @@ const BRIEFS = {
148
148
  does: 'Lists grants you hold, or with role issuer the grants you caused. An empty list means no grants of your own, not no access.',
149
149
  },
150
150
  ziggs_access_request: {
151
- does: 'Requests access to a specific resource. recipientId names the approver; refusals list eligible approvers. No conversation is needed.',
151
+ does: 'Requests access to a named resource, a connection (connectionTools), or wallet spend (spendingMaxAmount). recipientId names the approver; refusals list eligible approvers.',
152
152
  changes: 'creates a pending approval; grants nothing until approved',
153
153
  },
154
154
  ziggs_context_delegate: {
@@ -96,11 +96,11 @@ export declare class ContextGrantsClient {
96
96
  issueGrant(input: IssueContextGrantInput): Promise<GrantView>;
97
97
  /** Request-only endpoint: a successful call must still have granted no access. */
98
98
  requestAccess(input: {
99
- scopeKind: 'message' | 'artifact' | 'address' | 'agreement' | 'task' | 'person' | 'contact';
99
+ scopeKind: import('@ziggs-ai/contracts').AccessRequestScopeKind;
100
100
  scopeId?: string;
101
101
  agreementId?: string;
102
102
  reason: string;
103
- permission?: 'read' | 'reply' | 'work' | 'list';
103
+ permission?: 'read' | 'reply' | 'work' | 'list' | 'change';
104
104
  temporal?: 'from-now' | 'from-start';
105
105
  durationHours?: number;
106
106
  ownerId?: string;
@@ -108,6 +108,10 @@ export declare class ContextGrantsClient {
108
108
  recipientId?: string;
109
109
  /** Artifact only: who should read it, if not only the caller. One grant each. */
110
110
  holders?: AccessReader[];
111
+ /** Connection scope only: MCP tool names to request. */
112
+ connectionTools?: string[];
113
+ /** Wallet scope only: max spend after approval, in hundredths of a point. */
114
+ spendingMaxAmount?: number;
111
115
  contributionTo?: import('@ziggs-ai/contracts').ContributionTarget;
112
116
  releaseSource?: import('@ziggs-ai/contracts').ContributionSource;
113
117
  }, opts?: {
@@ -1,3 +1,5 @@
1
+ import type { ResourceAction } from '@ziggs-ai/contracts';
2
+ export type { ResourceAction, ResourceActionCall } from '@ziggs-ai/contracts';
1
3
  export declare const CONTEXT_OPEN_KINDS: readonly ["artifact", "task", "agreement"];
2
4
  export type ContextOpenKind = (typeof CONTEXT_OPEN_KINDS)[number];
3
5
  export type ContextOpenOutcome = 'ok' | 'unreadable' | 'hidden';
@@ -17,30 +19,6 @@ export interface ContextOpenBody {
17
19
  /** An HTML page comes as its text; true returns the HTML as written. */
18
20
  html?: boolean;
19
21
  }
20
- /** Backend-evaluated action, scoped to a resource. Never a permission token. */
21
- export interface ResourceActionCall {
22
- tool: string;
23
- args: Record<string, unknown>;
24
- required?: string[];
25
- unavailableReason?: string;
26
- approvers?: Array<{
27
- id: string;
28
- name: string | null;
29
- role: string;
30
- }>;
31
- }
32
- export interface ResourceAction extends Partial<ResourceActionCall> {
33
- action: string;
34
- state: 'available' | 'needs_decision' | 'unavailable' | 'not_evaluated';
35
- reasonCode?: string;
36
- reason?: unknown;
37
- scope?: {
38
- kind: string;
39
- id: string;
40
- agreementId?: string;
41
- };
42
- recovery?: ResourceActionCall;
43
- }
44
22
  export interface ContextOpenAccess {
45
23
  summary: string;
46
24
  document?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.42.19",
3
+ "version": "0.42.20",
4
4
  "description": "HTTP and WebSocket client for the Ziggs backend API",
5
5
  "homepage": "https://ziggsai.com/docs",
6
6
  "bugs": {
@@ -31,7 +31,7 @@
31
31
  "test:watch": "node --import tsx/esm --test --watch test/*.test.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@ziggs-ai/contracts": "0.52.0",
34
+ "@ziggs-ai/contracts": "0.53.5",
35
35
  "socket.io-client": "^4.7.0"
36
36
  },
37
37
  "keywords": [