@ziggs-ai/api-client 0.37.5 → 0.37.7

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) {
@@ -110,11 +110,16 @@ export const agreementClaimCapability = {
110
110
  type: 'object',
111
111
  description: 'Only when the listing\'s requiredConnections name a kind (e.g. ledger, customer): one of YOUR connections for each, as { "<kind>": "<connectionId>" }. The hire is granted exactly that connection and the grant ends with it. Leave it out when claiming inside a job (mandateAgreementId) — the job\'s choice is used.',
112
112
  },
113
+ hireFor: {
114
+ type: 'string',
115
+ enum: ['me', 'workspace'],
116
+ description: 'Only when hiring an agent\'s listing: who the hire is for. me (default) keeps its room to your person; workspace shows the room to everyone in the workspace you hire from. Ask your person when it is not clear.',
117
+ },
113
118
  },
114
119
  needsAgentId: true,
115
120
  handler: async (args, env) => {
116
121
  const declaredMandate = args['mandateAgreementId'];
117
- const { agreement, kind, room } = await claimOpenAgreement(args['agreementId'], fullCreds(env), { ...(typeof declaredMandate === 'string' && declaredMandate ? { mandateAgreementId: declaredMandate } : {}), ...(typeof args['parentAgreementId'] === 'string' ? { parentAgreementId: args['parentAgreementId'] } : {}), ...(typeof args['chatId'] === 'string' && args['chatId'] ? { chatId: args['chatId'] } : {}), ...(claimConnections(args['connections']) ?? {}) });
122
+ const { agreement, kind, room } = await claimOpenAgreement(args['agreementId'], fullCreds(env), { ...(typeof declaredMandate === 'string' && declaredMandate ? { mandateAgreementId: declaredMandate } : {}), ...(typeof args['parentAgreementId'] === 'string' ? { parentAgreementId: args['parentAgreementId'] } : {}), ...(typeof args['chatId'] === 'string' && args['chatId'] ? { chatId: args['chatId'] } : {}), ...(claimConnections(args['connections']) ?? {}), ...(args['hireFor'] === 'workspace' ? { hireFor: 'workspace' } : {}) });
118
123
  return presentClaimResult(agreement, kind, env, room);
119
124
  },
120
125
  };
@@ -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,
@@ -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';
@@ -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';
@@ -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,
@@ -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>;
@@ -331,6 +338,12 @@ export interface ClaimOptions {
331
338
  * takes the job's and names none.
332
339
  */
333
340
  connections?: Record<string, string>;
341
+ /**
342
+ * Who a hire of a listing is for. `me` (the default) keeps its room to the
343
+ * person; `workspace` makes the workspace the payer and shows the room to
344
+ * every member.
345
+ */
346
+ hireFor?: 'me' | 'workspace';
334
347
  }
335
348
  /**
336
349
  * Where a hire made in a room stands on getting its agent in.
@@ -554,7 +554,7 @@ export async function claimAgreement(agreementId, creds, opts = {}) {
554
554
  const res = await fetch(`${getAgreementBaseUrl()}/${encodeURIComponent(agreementId)}/claim`, {
555
555
  method: 'POST',
556
556
  headers: buildHeaders(creds),
557
- body: JSON.stringify({ ...(opts.mandateAgreementId ? { mandateAgreementId: opts.mandateAgreementId } : {}), ...(opts.parentAgreementId ? { parentAgreementId: opts.parentAgreementId } : {}), ...(opts.chatId ? { chatId: opts.chatId } : {}), ...(opts.connections && Object.keys(opts.connections).length ? { connections: opts.connections } : {}) }),
557
+ body: JSON.stringify({ ...(opts.mandateAgreementId ? { mandateAgreementId: opts.mandateAgreementId } : {}), ...(opts.parentAgreementId ? { parentAgreementId: opts.parentAgreementId } : {}), ...(opts.chatId ? { chatId: opts.chatId } : {}), ...(opts.connections && Object.keys(opts.connections).length ? { connections: opts.connections } : {}), ...(opts.hireFor === 'workspace' ? { hireFor: 'workspace' } : {}) }),
558
558
  });
559
559
  if (!res.ok) {
560
560
  const body = await res.text().catch(() => '');
@@ -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) {
@@ -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
@@ -104,6 +105,8 @@ export interface CreateTaskData {
104
105
  * the whole object for a task nobody needs reminding about.
105
106
  */
106
107
  checkBack?: CreateTaskCheckBackData;
108
+ /** What the title and description drew on. See {@link WriteSource}. */
109
+ sources?: WriteSource[];
107
110
  }
108
111
  /** See {@link CreateTaskData.checkBack}. */
109
112
  export interface CreateTaskCheckBackData {
@@ -125,6 +128,8 @@ export interface UpdateTaskStateData {
125
128
  * stateless crash-replay reproduces it.
126
129
  */
127
130
  idempotencyKey?: string;
131
+ /** What the result drew on. Recorded only when a result is written. */
132
+ sources?: WriteSource[];
128
133
  }
129
134
  export declare function updateTaskState(taskId: string, state: TaskState, data: UpdateTaskStateData | undefined, creds: Creds): Promise<TaskWriteConfirm>;
130
135
  export declare function getActiveTasksForAgent(agentId: string, creds: Creds): Promise<Task[]>;
@@ -145,6 +150,8 @@ export interface PlanReplaceStep {
145
150
  status?: 'pending' | 'in_progress' | 'completed' | 'skipped';
146
151
  /** Optional step output stored with this replace. */
147
152
  result?: unknown;
153
+ /** What this text drew on. See {@link WriteSource}. */
154
+ sources?: WriteSource[];
148
155
  }
149
156
  export declare function replaceTaskPlan(taskId: string, steps: PlanReplaceStep[], creds: Creds): Promise<TaskWriteConfirm>;
150
157
  /** Named-step progress — only the listed steps change. */
@@ -152,6 +159,8 @@ export type PlanStepPatch = {
152
159
  stepId: string;
153
160
  status: 'pending' | 'in_progress' | 'completed' | 'skipped';
154
161
  result?: unknown;
162
+ /** What this step drew on. See {@link WriteSource}. */
163
+ sources?: WriteSource[];
155
164
  };
156
165
  /**
157
166
  * Who the holder is waiting on, because its last act was asking them.
@@ -166,7 +175,7 @@ export type TaskWaitingOn = {
166
175
  id: string;
167
176
  };
168
177
  export declare function updateTaskPlanSteps(taskId: string, patches: PlanStepPatch[], creds: Creds, waitingOn?: TaskWaitingOn | null): Promise<TaskWriteConfirm>;
169
- 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>;
170
179
  export declare function reportTask(taskId: string, message: string | undefined, creds: Creds): Promise<TaskWriteConfirm>;
171
180
  export declare function setTaskSatisfaction(taskId: string, satisfaction: 'positive' | 'negative', creds: Creds): Promise<TaskWriteConfirm>;
172
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.37.5",
3
+ "version": "0.37.7",
4
4
  "description": "HTTP and WebSocket client for the Ziggs backend API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",