@ziggs-ai/api-client 0.37.4 → 0.37.6

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.
@@ -1,3 +1,4 @@
1
+ import { SOURCES_PARAM, sourcesArg } from './sources.js';
1
2
  import { delegateAgreement, getAgreement, proposeBroadcast, proposeDirectTo, } from '../http/AgreementClient.js';
2
3
  import { fullCreds } from './types.js';
3
4
  import { nextCall } from './nextCall.js';
@@ -56,6 +57,7 @@ const TERMS_PARAMS = {
56
57
  type: 'number',
57
58
  description: 'End the engagement after this many tasks.',
58
59
  },
60
+ sources: SOURCES_PARAM,
59
61
  };
60
62
  /** Pull the shared terms off a validated arg bag. */
61
63
  function termsFrom(args) {
@@ -77,6 +79,7 @@ function termsFrom(args) {
77
79
  ...(args['maxExecutions'] === undefined
78
80
  ? {}
79
81
  : { maxExecutions: args['maxExecutions'] }),
82
+ ...sourcesArg(args),
80
83
  };
81
84
  }
82
85
  function engagementKindFrom(args) {
@@ -1,3 +1,4 @@
1
+ import { SOURCES_PARAM, sourcesArg } from './sources.js';
1
2
  import { ARTIFACT_FILE_FORMATS, ArtifactsClient, } from '../http/ArtifactsClient.js';
2
3
  import { ContextGrantsClient } from '../http/ContextGrantsClient.js';
3
4
  import { ContextDiscoveryClient, } from '../http/ContextDiscoveryClient.js';
@@ -218,6 +219,7 @@ export const recordArtifactCapability = {
218
219
  'text is the in-Ziggs summary. Ziggs stores the link and does not fetch it. ' +
219
220
  'A grant on this artifact does not open the other system.',
220
221
  },
222
+ sources: SOURCES_PARAM,
221
223
  },
222
224
  needsAgentId: true,
223
225
  handler: async (args, env) => {
@@ -265,6 +267,7 @@ export const recordArtifactCapability = {
265
267
  contentType,
266
268
  idempotencyKey: args['idempotencyKey'],
267
269
  ...(externalRef ? { externalRef } : {}),
270
+ ...sourcesArg(args),
268
271
  });
269
272
  return {
270
273
  ok: true,
@@ -50,6 +50,5 @@ export declare const RESOURCE_UNREADABLE_MESSAGE = "This exists and you cannot r
50
50
  export declare function explainRefusedRead(kind: 'agreement' | 'task' | 'chat' | 'artifact', id: string, env: CapabilityEnv): Promise<RefusedRead | null>;
51
51
  export declare const openCapability: CapabilityDefinition;
52
52
  export declare const accessExplainCapability: CapabilityDefinition;
53
- export declare const contextRequestCapability: CapabilityDefinition;
54
53
  export declare const accessRequestCapability: CapabilityDefinition;
55
54
  export declare const CONTEXT_CAPABILITIES: CapabilityDefinition[];
@@ -391,36 +391,6 @@ export const accessExplainCapability = {
391
391
  return presentOpenResult(result, env);
392
392
  },
393
393
  };
394
- export const contextRequestCapability = {
395
- key: 'context_request',
396
- names: { sdk: 'context_request', mcp: 'ziggs_context_request' },
397
- title: 'Ask an owner for artifact access',
398
- descriptions: {
399
- sdk: 'Ask a human owner for temporary read-only access to one artifact you were given a reference for. Use your existing chat with that owner. Creates an approval agreement; gives no access until the owner approves. You are the only recipient. After approval, open the original artifact. Never use a generic service agreement as a substitute for this access request.',
400
- },
401
- annotation: 'destructive', needsAgentId: true,
402
- params: {
403
- artifactId: { type: 'string', required: true },
404
- chatId: { type: 'string', required: true },
405
- ownerId: { type: 'string', required: true, description: 'Who to ask, from your work brief: workBrief.actingFor.customer.id or workBrief.actingFor.operator.id. Anyone else is refused, and the refusal lists who you can ask.' },
406
- reason: { type: 'string', required: true, description: 'Purpose, including whom you will summarize the artifact to' },
407
- durationHours: { type: 'number', description: 'Integer 1–168 hours after approval; default 24' },
408
- idempotencyKey: { type: 'string', description: 'Reuse for the same request; do not create duplicate approval cards' },
409
- },
410
- handler: async (args, env) => {
411
- for (const key of ['artifactId', 'chatId', 'ownerId', 'reason'])
412
- if (typeof args[key] !== 'string' || !String(args[key]).trim())
413
- throw new Error(`${key} is required`);
414
- const durationHours = args.durationHours === undefined ? 24 : Number(args.durationHours);
415
- if (!Number.isInteger(durationHours) || durationHours < 1 || durationHours > 168)
416
- throw new Error('durationHours must be an integer between 1 and 168');
417
- const creds = fullCreds(env);
418
- const result = await new ContextGrantsClient(creds.operatorKey, creds.agentId, env.baseUrl).requestArtifactAccess(args.artifactId, {
419
- chatId: args.chatId, ownerId: args.ownerId, reason: args.reason, durationHours,
420
- }, { idempotencyKey: args.idempotencyKey, laneId: creds.laneId });
421
- return { ...result, outcome: 'pending', state: 'requested', appUrl: `${(env.webUrl ?? 'https://ziggsai.com').replace(/\/$/, '')}/app/agreements/${encodeURIComponent(result.agreementId)}`, note: `${result.message ?? 'Waiting for the artifact owner.'} No access granted yet; open the original artifact only after approval.` };
422
- },
423
- };
424
394
  /** A suggested request still needs a purpose; it is never a grant or an approval. */
425
395
  function requestAccessAction(args, env) {
426
396
  return {
@@ -543,7 +513,6 @@ export const CONTEXT_CAPABILITIES = [
543
513
  openCapability,
544
514
  accessExplainCapability,
545
515
  accessRequestCapability,
546
- contextRequestCapability,
547
516
  contextDelegateCapability,
548
517
  contextExpandReachCapability,
549
518
  contextDiscoverGrantableCapability,
@@ -1,4 +1,5 @@
1
1
  export { type CapabilitySurface, type CapabilityAnnotation, type CapabilityParam, type CapabilityEnv, type CapabilityDefinition, fullCreds, rethrowWithContext, } from './types.js';
2
+ export { WRITE_SOURCE_KINDS, SOURCES_DESCRIPTION, SOURCES_PARAM, sourcesArg, type WriteSource, type WriteSourceKind, } from './sources.js';
2
3
  export { type McpBrief, type McpDoor, hasMcpBrief, mcpBriefNames, mcpDescription, } from './mcpBriefs.js';
3
4
  export { nextCall, nextCallsFromUntrustedContent, isStaleAdvertisedAction, peerPrincipalId, isPersonaFace, workContextFromEnv, type NextCall, type NextCallOutcome, type NextCallEffects, type NextCallHold, type NextCallOptions, type WorkContext, } from './nextCall.js';
4
5
  export { AGREEMENT_VERB_CAPABILITIES, LISTING_DOOR_CAPABILITIES, agreementBuyCapability, agreementBidCapability, agreementBrokerCapability, agreementRequestCapability, agreementHandoffCapability, agreementSubcontractCapability, } from './agreementVerbs.js';
@@ -12,7 +13,7 @@ export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, presentTa
12
13
  export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.js';
13
14
  export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
14
15
  export { GRANTS_CAPABILITIES, listGrantsCapability } from './grants.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
+ export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, accessRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, explainRefusedRead, RESOURCE_HIDDEN_MESSAGE, RESOURCE_UNREADABLE_MESSAGE, type RefusedRead, } from './context.js';
16
17
  export { CONNECTION_CAPABILITIES, connectionProxyCapability, requestConnectionCapability, } from './connections.js';
17
18
  export { DISCOVERY_CAPABILITIES, agentSearchCapability, agentGetCapability, } from './discovery.js';
18
19
  export { ARTIFACT_CAPABILITIES, recordArtifactCapability, listArtifactsCapability, findArtifactsCapability, type UnsearchedContext, shareArtifactCapability, attachArtifactCapability, uploadArtifactUrlCapability, completeArtifactFileCapability, downloadArtifactCapability, reextractArtifactCapability, } from './artifacts.js';
@@ -1,4 +1,5 @@
1
1
  export { fullCreds, rethrowWithContext, } from './types.js';
2
+ export { WRITE_SOURCE_KINDS, SOURCES_DESCRIPTION, SOURCES_PARAM, sourcesArg, } from './sources.js';
2
3
  export { hasMcpBrief, mcpBriefNames, mcpDescription, } from './mcpBriefs.js';
3
4
  export { nextCall, nextCallsFromUntrustedContent, isStaleAdvertisedAction, peerPrincipalId, isPersonaFace, workContextFromEnv, } from './nextCall.js';
4
5
  export { AGREEMENT_VERB_CAPABILITIES, LISTING_DOOR_CAPABILITIES, agreementBuyCapability, agreementBidCapability, agreementBrokerCapability, agreementRequestCapability, agreementHandoffCapability, agreementSubcontractCapability, } from './agreementVerbs.js';
@@ -12,7 +13,7 @@ export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, presentTa
12
13
  export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.js';
13
14
  export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
14
15
  export { GRANTS_CAPABILITIES, listGrantsCapability } from './grants.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
+ export { CONTEXT_CAPABILITIES, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, accessRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, explainRefusedRead, RESOURCE_HIDDEN_MESSAGE, RESOURCE_UNREADABLE_MESSAGE, } from './context.js';
16
17
  export { CONNECTION_CAPABILITIES, connectionProxyCapability, requestConnectionCapability, } from './connections.js';
17
18
  export { DISCOVERY_CAPABILITIES, agentSearchCapability, agentGetCapability, } from './discovery.js';
18
19
  export { ARTIFACT_CAPABILITIES, recordArtifactCapability, listArtifactsCapability, findArtifactsCapability, shareArtifactCapability, attachArtifactCapability, uploadArtifactUrlCapability, completeArtifactFileCapability, downloadArtifactCapability, reextractArtifactCapability, } from './artifacts.js';
@@ -1,3 +1,4 @@
1
+ import { SOURCES_PARAM, sourcesArg } from './sources.js';
1
2
  import { IntroductionsClient } from '../http/IntroductionsClient.js';
2
3
  import { nextCall } from './nextCall.js';
3
4
  import { fullCreds } from './types.js';
@@ -34,6 +35,7 @@ export const mintIntroductionCapability = {
34
35
  type: 'string',
35
36
  description: 'One line for the other side to read when they open it — why you want to connect.',
36
37
  },
38
+ sources: SOURCES_PARAM,
37
39
  },
38
40
  needsAgentId: true,
39
41
  handler: async (args, env) => {
@@ -43,6 +45,7 @@ export const mintIntroductionCapability = {
43
45
  ...(args['venue'] ? { venue: args['venue'] } : {}),
44
46
  ...(args['venueRef'] ? { venueRef: args['venueRef'] } : {}),
45
47
  ...(args['note'] ? { note: args['note'] } : {}),
48
+ ...sourcesArg(args),
46
49
  });
47
50
  return {
48
51
  introduction: intro,
@@ -5,10 +5,9 @@ export declare function webAppOrigin(env: CapabilityEnv): string;
5
5
  *
6
6
  * Opening a chat is itself the admission: the backend issues a standing from-now
7
7
  * write grant to each side as it creates the room, so both delegates can
8
- * read and post immediately. Do NOT tell agents to follow chat_open with an
9
- * issue_grant on that same new chat — that only mints a duplicate grant carrying
10
- * the default 30-day expiry. issue_grant / context_delegate are for scopes that
11
- * already exist (an older chat, an agreement, an org).
8
+ * read and post immediately. Sharing what already exists is artifact_share for
9
+ * one artifact, a chat_open invite for a room, or context_delegate for a slice
10
+ * of a grant the agent holds.
12
11
  */
13
12
  export declare function linkIsReachOnly(env: CapabilityEnv): string;
14
13
  export declare const listLinksCapability: CapabilityDefinition;
@@ -10,14 +10,13 @@ export function webAppOrigin(env) {
10
10
  *
11
11
  * Opening a chat is itself the admission: the backend issues a standing from-now
12
12
  * write grant to each side as it creates the room, so both delegates can
13
- * read and post immediately. Do NOT tell agents to follow chat_open with an
14
- * issue_grant on that same new chat — that only mints a duplicate grant carrying
15
- * the default 30-day expiry. issue_grant / context_delegate are for scopes that
16
- * already exist (an older chat, an agreement, an org).
13
+ * read and post immediately. Sharing what already exists is artifact_share for
14
+ * one artifact, a chat_open invite for a room, or context_delegate for a slice
15
+ * of a grant the agent holds.
17
16
  */
18
17
  export function linkIsReachOnly(env) {
19
18
  return env.surface === 'mcp'
20
- ? 'A link is reach-only — it shares no context on its own. Open a chat with the PERSON on the other side (ziggs_chat_open, participantId = that link\'s `peer.id`): delivery lands in their mailbox and whoever runs that side picks it up, which is not yours to choose. Use `peer.id`, never a principal out of `parties` — those are display faces, and chat_open refuses a face because it names no single party. Opening the room admits both sides to read and post from then on. To share context that already exists, issue a grant on it with ziggs_context_issue_grant or share a slice of one you hold with ziggs_context_delegate.'
19
+ ? 'A link is reach-only — it shares no context on its own. Open a chat with the PERSON on the other side (ziggs_chat_open, participantId = that link\'s `peer.id`): delivery lands in their mailbox and whoever runs that side picks it up, which is not yours to choose. Use `peer.id`, never a principal out of `parties` — those are display faces, and chat_open refuses a face because it names no single party. Opening the room admits both sides to read and post from then on. To share context that already exists, share one artifact with ziggs_artifact_share, invite them into a room you hold with ziggs_chat_open (chatId plus participantIds), or share a slice of a grant you hold with ziggs_context_delegate.'
21
20
  : 'A link is reach-only — it shares no context on its own. Open a chat with the PERSON on the other side; delivery lands in their mailbox and whoever runs that side picks it up, which is not yours to choose. Opening the room admits both sides to it from then on. To share context that already exists, share a slice of a grant you hold with context_delegate, or ask the peer owner to issue one.';
22
21
  }
23
22
  const LINK_STATUSES = ['active', 'open', 'cancelled', 'all'];
@@ -84,7 +83,7 @@ export const listLinksCapability = {
84
83
  readPlan.push(nextCall(env, 'chat_open', undefined, 'open a room with a linked peer: participantId is that link\'s `peer.id`. Do NOT pass a principal out of `parties` — those are display faces and chat_open refuses them'));
85
84
  }
86
85
  if (active.length) {
87
- readPlan.push(nextCall(env, 'context_issue_grant', undefined, 'share context that already exists: a link does not share any on its own'));
86
+ readPlan.push(nextCall(env, 'artifact_share', undefined, 'share context that already exists: a link does not share any on its own. One artifact with artifact_share; a room you hold by inviting them with chat_open (chatId plus participantIds)'));
88
87
  }
89
88
  return {
90
89
  count: links.length,
@@ -137,14 +137,6 @@ const BRIEFS = {
137
137
  does: 'Asks for access to an artifact, chat, agreement or task for this agent. recipientId names who decides (a refusal lists who you can ask); an artifact needs chatId.',
138
138
  changes: 'creates a pending approval; grants nothing until approved',
139
139
  },
140
- ziggs_context_request: {
141
- does: 'Asks an artifact’s owner for read access to it, for 1 to 168 hours.',
142
- changes: 'creates a pending approval; grants nothing until approved',
143
- },
144
- ziggs_context_issue_grant: {
145
- does: 'Admits another agent to a room. Agreement, org, artifact and task grants need your person’s authority.',
146
- changes: 'admits it, pending until the people there consent',
147
- },
148
140
  ziggs_context_delegate: {
149
141
  does: 'Gives another agent a narrower slice of a grant you hold.',
150
142
  changes: 'grants it, or opens a request its owner approves (pending_approval)',
@@ -204,7 +196,7 @@ const BRIEFS = {
204
196
  changes: 'the old steps are replaced',
205
197
  },
206
198
  ziggs_task_set_result: {
207
- does: 'Closes a task as completed, failed or cancelled; the result is for the next agent, a person reads it in your conversation. The agreement stays active.',
199
+ does: 'Closes a task as completed or failed; the result is for the next agent, a person reads it in your conversation. The agreement stays active.',
208
200
  changes: 'closes the task, proving nobody read or paid; the same idempotencyKey is a no-op',
209
201
  },
210
202
  ziggs_task_cancel: {
@@ -28,7 +28,6 @@ const REQUIRED_ARGS = {
28
28
  agreement_subcontract: ['parentAgreementId', 'executorId', 'description'],
29
29
  agreement_respond: ['agreementId'],
30
30
  introduction_redeem: ['token'],
31
- context_issue_grant: ['holderId', 'scopeKind', 'scopeId'],
32
31
  artifact_share: ['artifactId', 'holderId'],
33
32
  context_delegate: ['parentGrantId', 'holderId', 'scopeKind', 'scopeId', 'temporal'],
34
33
  task_create: ['agreementId', 'description'],
@@ -59,7 +58,6 @@ const HTTP_BINDINGS = {
59
58
  path: '/agreements/:agreementId/approvals/:partyId',
60
59
  },
61
60
  marketplace_view: { method: 'GET', path: '/marketplace/offers' },
62
- context_issue_grant: { method: 'POST', path: '/context/grants' },
63
61
  artifact_share: { method: 'POST', path: '/context/artifacts/:artifactId/share' },
64
62
  context_delegate: { method: 'POST', path: '/context/grants/:parentGrantId/delegate' },
65
63
  open: { method: 'POST', path: '/context/open' },
@@ -74,11 +72,9 @@ const HTTP_BINDINGS = {
74
72
  };
75
73
  /**
76
74
  * Intentional surface exclusions. A ready next call has to exist as a tool
77
- * on the calling surface — SDK context exposes delegate, not a top-level
78
- * issue grant (tool-surface-parity).
75
+ * on the calling surface (tool-surface-parity).
79
76
  */
80
77
  const SURFACE_EXPOSURE = {
81
- context_issue_grant: ['mcp'],
82
78
  // The hosted SDK surface enumerates its own work with task_list and reads a
83
79
  // task from the wake it arrived on; ziggs_task_get is the MCP delegate's
84
80
  // one-task read. Naming it to an SDK agent would offer a tool it cannot call.
@@ -98,9 +94,6 @@ const MATERIAL_EFFECTS = {
98
94
  introduction_redeem: {
99
95
  relationship: 'a stranger redeem stages a link both humans must approve — it is not a live connection yet',
100
96
  },
101
- context_issue_grant: {
102
- disclosure: 'issues a grant that widens who can read that scope',
103
- },
104
97
  link_propose: {
105
98
  relationship: 'proposes a reach-only link; nothing is shared until they accept',
106
99
  },
@@ -0,0 +1,29 @@
1
+ import type { CapabilityParam } from './types.js';
2
+ /**
3
+ * What a write drew on. Every write that carries text the agent composed
4
+ * can say it: things in Ziggs by kind and id, or outside things as a url.
5
+ * Never shown to anyone; the writer's company admin reads it back by query.
6
+ */
7
+ export declare const WRITE_SOURCE_KINDS: readonly ["message", "artifact", "task_result", "task_plan_step", "url"];
8
+ export type WriteSourceKind = (typeof WRITE_SOURCE_KINDS)[number];
9
+ /**
10
+ * - `message`: `id` is the messageId, `chatId` its room.
11
+ * - `artifact`: `id` is the artifactId.
12
+ * - `task_result`: `id` is the taskId.
13
+ * - `task_plan_step`: `id` is the stepId, `taskId` its task.
14
+ * - `url`: `value` is the outside source.
15
+ */
16
+ export interface WriteSource {
17
+ kind: WriteSourceKind;
18
+ id?: string;
19
+ chatId?: string;
20
+ taskId?: string;
21
+ value?: string;
22
+ }
23
+ /** One line, shared by every tool that takes `sources`: it is repeated per tool. */
24
+ export declare const SOURCES_DESCRIPTION = "What this text drew on: {kind,id} for a message (+chatId), artifact, task_result or task_plan_step (+taskId); {kind:\"url\",value} outside. [] = nothing more.";
25
+ export declare const SOURCES_PARAM: CapabilityParam;
26
+ /** The `sources` a tool call carried, ready for the request body. */
27
+ export declare function sourcesArg(args: Record<string, unknown>): {
28
+ sources: WriteSource[];
29
+ } | Record<string, never>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * What a write drew on. Every write that carries text the agent composed
3
+ * can say it: things in Ziggs by kind and id, or outside things as a url.
4
+ * Never shown to anyone; the writer's company admin reads it back by query.
5
+ */
6
+ export const WRITE_SOURCE_KINDS = [
7
+ 'message',
8
+ 'artifact',
9
+ 'task_result',
10
+ 'task_plan_step',
11
+ 'url',
12
+ ];
13
+ /** One line, shared by every tool that takes `sources`: it is repeated per tool. */
14
+ export const SOURCES_DESCRIPTION = 'What this text drew on: {kind,id} for a message (+chatId), artifact, task_result or task_plan_step (+taskId); {kind:"url",value} outside. [] = nothing more.';
15
+ export const SOURCES_PARAM = {
16
+ type: 'array',
17
+ description: SOURCES_DESCRIPTION,
18
+ items: {
19
+ type: 'object',
20
+ properties: {
21
+ kind: { type: 'string', enum: WRITE_SOURCE_KINDS },
22
+ id: { type: 'string' },
23
+ chatId: { type: 'string' },
24
+ taskId: { type: 'string' },
25
+ value: { type: 'string' },
26
+ },
27
+ required: ['kind'],
28
+ },
29
+ };
30
+ /** The `sources` a tool call carried, ready for the request body. */
31
+ export function sourcesArg(args) {
32
+ const raw = args['sources'];
33
+ return Array.isArray(raw) ? { sources: raw } : {};
34
+ }
@@ -1,3 +1,4 @@
1
+ import type { WriteSource } from '../capabilities/sources.js';
1
2
  import { type Creds, type Agreement, type EngagementKind, type BroadcastAudience } from '../types.js';
2
3
  /**
3
4
  * Shared proposal terms. When `engagementKind` is omitted the server defaults to `service`.
@@ -8,6 +9,8 @@ import { type Creds, type Agreement, type EngagementKind, type BroadcastAudience
8
9
  */
9
10
  export interface ProposeTerms {
10
11
  description: string;
12
+ /** What this text drew on. See {@link WriteSource}. */
13
+ sources?: WriteSource[];
11
14
  price?: number;
12
15
  lifecycle?: string;
13
16
  expiresAt?: string;
@@ -125,6 +128,8 @@ export declare function proposeDirectTo(input: ProposeDirectInput, creds: Creds)
125
128
  export declare function proposeBroadcast(input: ProposeBroadcastInput, creds: Creds): Promise<Agreement>;
126
129
  export interface DelegateAgreementData {
127
130
  description: string;
131
+ /** What this text drew on. See {@link WriteSource}. */
132
+ sources?: WriteSource[];
128
133
  executorId: string;
129
134
  /** Omit it and the server uses the parent agreement's own chat. */
130
135
  chatId?: string;
@@ -208,6 +213,8 @@ export interface CounterAgreementData {
208
213
  conversationAllowanceScope?: 'direct' | 'subtree';
209
214
  interactionMode?: 'messages' | 'tasks' | 'both';
210
215
  description?: string;
216
+ /** What this text drew on. See {@link WriteSource}. */
217
+ sources?: WriteSource[];
211
218
  }
212
219
  export declare function counterAgreement(agreementId: string, counter: CounterAgreementData, creds: Creds): Promise<Agreement>;
213
220
  export declare function getAgreementStatus(agreementId: string, creds: Creds): Promise<unknown | null>;
@@ -1,3 +1,4 @@
1
+ import type { WriteSource } from '../capabilities/sources.js';
1
2
  import type { ListReachableArtifactsResult } from '@ziggs-ai/contracts';
2
3
  /**
3
4
  * Inline `POST /artifacts` body cap (matches backend
@@ -91,6 +92,8 @@ export interface WriteArtifactInput {
91
92
  * The `text` is the in-Ziggs summary. Ziggs does not fetch the URL.
92
93
  */
93
94
  externalRef?: ArtifactExternalRef;
95
+ /** What this text drew on. See {@link WriteSource}. */
96
+ sources?: WriteSource[];
94
97
  }
95
98
  /** Every file format the server stores — the contracts list, re-exported under the names callers already use. */
96
99
  export { ARTIFACT_FILE_FORMATS, type ArtifactExternalRef, type ArtifactFileFormat } from '@ziggs-ai/contracts';
@@ -194,6 +194,7 @@ export class ArtifactsClient {
194
194
  ...(input.externalRef
195
195
  ? { externalRef: input.externalRef }
196
196
  : {}),
197
+ ...(input.sources ? { sources: input.sources } : {}),
197
198
  }),
198
199
  });
199
200
  const body = await res.text().catch(() => '');
@@ -1,3 +1,4 @@
1
+ import type { WriteSource } from '../capabilities/sources.js';
1
2
  import type { ChatReadDto } from '@ziggs-ai/contracts';
2
3
  import type { MessageDelivery as WireMessageDelivery, SendChatMessageResult as WireSendChatMessageResult } from '@ziggs-ai/contracts';
3
4
  import { type Creds } from '../types.js';
@@ -69,6 +70,8 @@ export interface SendChatMessageInput {
69
70
  /** Governing service agreement; independent of representation. */
70
71
  conversationAgreementId?: string;
71
72
  taskId?: string;
73
+ /** What this text drew on. See {@link WriteSource}. */
74
+ sources?: WriteSource[];
72
75
  }
73
76
  /**
74
77
  * Where the server says a send landed.
@@ -130,6 +130,7 @@ export async function sendChatMessage(input, creds) {
130
130
  underAgreementId: input.underAgreementId,
131
131
  conversationAgreementId: input.conversationAgreementId,
132
132
  taskId: input.taskId,
133
+ ...(input.sources ? { sources: input.sources } : {}),
133
134
  }),
134
135
  });
135
136
  if (!res.ok) {
@@ -115,18 +115,6 @@ export declare class ContextGrantsClient {
115
115
  idempotencyKey?: string;
116
116
  laneId?: string;
117
117
  }): Promise<AccessRequestResult>;
118
- requestArtifactAccess(artifactId: string, input: {
119
- chatId: string;
120
- ownerId: string;
121
- reason: string;
122
- durationHours?: number;
123
- }, opts?: {
124
- idempotencyKey?: string;
125
- laneId?: string;
126
- }): Promise<{
127
- status: 'pending_approval';
128
- agreementId: string;
129
- } & RequestSentTo>;
130
118
  delegateGrant(parentGrantId: string, input: DelegateContextGrantInput, opts?: {
131
119
  idempotencyKey?: string;
132
120
  }): Promise<DelegateContextGrantResult>;
@@ -94,24 +94,6 @@ export class ContextGrantsClient {
94
94
  }
95
95
  return { status: 'pending_approval', agreementId: result.agreementId, ...common };
96
96
  }
97
- async requestArtifactAccess(artifactId, input, opts) {
98
- const res = await fetch(`${this.baseUrl}/context/artifacts/${encodeURIComponent(artifactId)}/access-requests`, {
99
- method: 'POST',
100
- headers: buildOperatorHeaders(this.operatorKey, this.agentId, {
101
- 'content-type': 'application/json',
102
- ...(opts?.idempotencyKey ? { 'Idempotency-Key': opts.idempotencyKey } : {}),
103
- ...(opts?.laneId ? { 'x-ziggs-lane': opts.laneId } : {}),
104
- }),
105
- body: JSON.stringify(input),
106
- });
107
- const body = await res.text().catch(() => '');
108
- if (!res.ok)
109
- throwApiError(res, body, `requestArtifactAccess failed: ${res.status}`);
110
- const result = JSON.parse(body);
111
- if (result.status !== 'pending_approval' || !result.agreementId)
112
- throw new Error('Expected a pending artifact access request');
113
- return { status: 'pending_approval', agreementId: result.agreementId, ...sentToOf(result) };
114
- }
115
97
  async delegateGrant(parentGrantId, input, opts) {
116
98
  const res = await fetch(`${this.baseUrl}/context/grants/${encodeURIComponent(parentGrantId)}/delegate`, {
117
99
  method: 'POST',
@@ -1,3 +1,4 @@
1
+ import type { WriteSource } from '../capabilities/sources.js';
1
2
  /** What became of one hello. `expired` is derived by the server, not stored. */
2
3
  export type IntroductionStatus = 'open' | 'redeemed' | 'declined' | 'revoked' | 'expired';
3
4
  export type IntroductionOutcome = 'link_pending' | 'already_teammates' | 'already_linked';
@@ -56,6 +57,8 @@ export interface MintIntroductionInput {
56
57
  venue?: string;
57
58
  venueRef?: string;
58
59
  note?: string;
60
+ /** What this text drew on. See {@link WriteSource}. */
61
+ sources?: WriteSource[];
59
62
  }
60
63
  /**
61
64
  * Introduction tokens — the one object to exchange when you meet an
@@ -1,6 +1,9 @@
1
+ import type { WriteSource } from '../capabilities/sources.js';
1
2
  import { type Creds, type Agreement, type BroadcastAudience } from '../types.js';
2
3
  export interface PublishOfferPayload {
3
4
  description: string;
5
+ /** What this text drew on. See {@link WriteSource}. */
6
+ sources?: WriteSource[];
4
7
  price?: number;
5
8
  lifecycle?: string;
6
9
  expiresAt?: string;
@@ -1,3 +1,4 @@
1
+ import type { WriteSource } from '../capabilities/sources.js';
1
2
  import { type Creds, type Task, type TaskState } from '../types.js';
2
3
  /**
3
4
  * Thin confirmation from task write verbs. Full object stays on
@@ -48,6 +49,8 @@ export interface CreateTaskGraphNodeData {
48
49
  assigneeId?: string;
49
50
  waitsOn?: string[];
50
51
  joinKind?: 'all' | 'any';
52
+ /** A yes/no question over the steps this one waits on; it runs only on yes. */
53
+ runIf?: string;
51
54
  }
52
55
  export interface CreateTaskGraphData {
53
56
  nodes: CreateTaskGraphNodeData[];
@@ -102,6 +105,8 @@ export interface CreateTaskData {
102
105
  * the whole object for a task nobody needs reminding about.
103
106
  */
104
107
  checkBack?: CreateTaskCheckBackData;
108
+ /** What the title and description drew on. See {@link WriteSource}. */
109
+ sources?: WriteSource[];
105
110
  }
106
111
  /** See {@link CreateTaskData.checkBack}. */
107
112
  export interface CreateTaskCheckBackData {
@@ -123,6 +128,8 @@ export interface UpdateTaskStateData {
123
128
  * stateless crash-replay reproduces it.
124
129
  */
125
130
  idempotencyKey?: string;
131
+ /** What the result drew on. Recorded only when a result is written. */
132
+ sources?: WriteSource[];
126
133
  }
127
134
  export declare function updateTaskState(taskId: string, state: TaskState, data: UpdateTaskStateData | undefined, creds: Creds): Promise<TaskWriteConfirm>;
128
135
  export declare function getActiveTasksForAgent(agentId: string, creds: Creds): Promise<Task[]>;
@@ -143,6 +150,8 @@ export interface PlanReplaceStep {
143
150
  status?: 'pending' | 'in_progress' | 'completed' | 'skipped';
144
151
  /** Optional step output stored with this replace. */
145
152
  result?: unknown;
153
+ /** What this text drew on. See {@link WriteSource}. */
154
+ sources?: WriteSource[];
146
155
  }
147
156
  export declare function replaceTaskPlan(taskId: string, steps: PlanReplaceStep[], creds: Creds): Promise<TaskWriteConfirm>;
148
157
  /** Named-step progress — only the listed steps change. */
@@ -150,6 +159,8 @@ export type PlanStepPatch = {
150
159
  stepId: string;
151
160
  status: 'pending' | 'in_progress' | 'completed' | 'skipped';
152
161
  result?: unknown;
162
+ /** What this step drew on. See {@link WriteSource}. */
163
+ sources?: WriteSource[];
153
164
  };
154
165
  /**
155
166
  * Who the holder is waiting on, because its last act was asking them.
@@ -164,7 +175,7 @@ export type TaskWaitingOn = {
164
175
  id: string;
165
176
  };
166
177
  export declare function updateTaskPlanSteps(taskId: string, patches: PlanStepPatch[], creds: Creds, waitingOn?: TaskWaitingOn | null): Promise<TaskWriteConfirm>;
167
- export declare function updateTaskPlanStep(taskId: string, stepId: string, status: string, result: unknown, creds: Creds, waitingOn?: TaskWaitingOn | null): Promise<TaskWriteConfirm>;
178
+ export declare function updateTaskPlanStep(taskId: string, stepId: string, status: string, result: unknown, creds: Creds, waitingOn?: TaskWaitingOn | null, sources?: WriteSource[]): Promise<TaskWriteConfirm>;
168
179
  export declare function reportTask(taskId: string, message: string | undefined, creds: Creds): Promise<TaskWriteConfirm>;
169
180
  export declare function setTaskSatisfaction(taskId: string, satisfaction: 'positive' | 'negative', creds: Creds): Promise<TaskWriteConfirm>;
170
181
  export interface ListTasksOptions {
@@ -335,7 +335,7 @@ export async function updateTaskPlanSteps(taskId, patches, creds, waitingOn) {
335
335
  throw new Error('Invalid response: task write confirm not found');
336
336
  return confirm;
337
337
  }
338
- export async function updateTaskPlanStep(taskId, stepId, status, result, creds, waitingOn) {
338
+ export async function updateTaskPlanStep(taskId, stepId, status, result, creds, waitingOn, sources) {
339
339
  if (!taskId)
340
340
  throw new Error('updateTaskPlanStep: taskId is required');
341
341
  if (!stepId)
@@ -354,6 +354,7 @@ export async function updateTaskPlanStep(taskId, stepId, status, result, creds,
354
354
  status,
355
355
  ...(result !== undefined && { result }),
356
356
  ...(waitingOn !== undefined ? { waitingOn } : {}),
357
+ ...(sources ? { sources } : {}),
357
358
  }),
358
359
  });
359
360
  if (!res.ok) {
package/dist/types.d.ts CHANGED
@@ -112,6 +112,20 @@ export interface Task {
112
112
  } | null;
113
113
  graphNodeId?: string | null;
114
114
  heldByGraphReview?: boolean;
115
+ /**
116
+ * A graph step that runs only if a yes/no question holds over the steps it
117
+ * waits on. Once asked: `run`, `skipped` (closed cancelled without running),
118
+ * `held` (waiting for the buyer to acknowledge its plan) or `buyer_run`.
119
+ */
120
+ runIf?: {
121
+ question: string;
122
+ outcome?: 'run' | 'skipped' | 'held' | 'buyer_run';
123
+ answer?: 'yes' | 'no' | null;
124
+ confidence?: number | null;
125
+ reason?: string;
126
+ decidedAt?: string;
127
+ decidedBy?: string | null;
128
+ } | null;
115
129
  plan?: {
116
130
  steps?: PlanStep[];
117
131
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.37.4",
3
+ "version": "0.37.6",
4
4
  "description": "HTTP and WebSocket client for the Ziggs backend API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",