@ziggs-ai/api-client 0.1.3 → 0.1.5

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.
Files changed (72) hide show
  1. package/README.md +13 -7
  2. package/dist/ConnectionManager.d.ts +46 -0
  3. package/dist/ConnectionManager.js +132 -0
  4. package/dist/http/AgentSearchClient.d.ts +36 -0
  5. package/dist/http/AgentSearchClient.js +72 -0
  6. package/dist/http/AgreementClient.d.ts +153 -0
  7. package/dist/http/AgreementClient.js +477 -0
  8. package/dist/http/ArtifactsClient.d.ts +48 -0
  9. package/dist/http/ArtifactsClient.js +90 -0
  10. package/dist/http/ChatClient.d.ts +34 -0
  11. package/dist/http/ChatClient.js +104 -0
  12. package/dist/http/ContextDiscoveryClient.d.ts +23 -0
  13. package/dist/http/ContextDiscoveryClient.js +35 -0
  14. package/dist/http/ContextReadClient.d.ts +33 -0
  15. package/dist/http/ContextReadClient.js +54 -0
  16. package/dist/http/MarketplaceClient.d.ts +19 -0
  17. package/dist/http/MarketplaceClient.js +72 -0
  18. package/dist/http/MessagesClient.d.ts +26 -0
  19. package/dist/http/MessagesClient.js +49 -0
  20. package/dist/http/ScopeClient.d.ts +33 -0
  21. package/dist/http/ScopeClient.js +39 -0
  22. package/dist/http/TaskClient.d.ts +75 -0
  23. package/dist/http/TaskClient.js +352 -0
  24. package/dist/http/TelemetryClient.d.ts +11 -0
  25. package/dist/http/TelemetryClient.js +53 -0
  26. package/dist/http/index.d.ts +16 -0
  27. package/dist/http/index.js +11 -0
  28. package/dist/index.d.ts +9 -0
  29. package/{src → dist}/index.js +2 -12
  30. package/dist/shared/runtimeLog.d.ts +14 -0
  31. package/dist/shared/runtimeLog.js +64 -0
  32. package/dist/types.d.ts +130 -0
  33. package/dist/types.js +50 -0
  34. package/dist/utils/urlUtils.d.ts +2 -0
  35. package/dist/utils/urlUtils.js +8 -0
  36. package/dist/websocket/ControlSocket.d.ts +13 -0
  37. package/dist/websocket/ControlSocket.js +37 -0
  38. package/dist/websocket/WebSocketClient.d.ts +71 -0
  39. package/dist/websocket/WebSocketClient.js +233 -0
  40. package/dist/websocket/index.js +1 -0
  41. package/package.json +20 -7
  42. package/src/ConnectionManager.ts +172 -0
  43. package/src/http/AgentSearchClient.ts +115 -0
  44. package/src/http/AgreementClient.ts +721 -0
  45. package/src/http/ArtifactsClient.ts +133 -0
  46. package/src/http/ChatClient.ts +147 -0
  47. package/src/http/ContextDiscoveryClient.ts +52 -0
  48. package/src/http/ContextReadClient.ts +83 -0
  49. package/src/http/MarketplaceClient.ts +94 -0
  50. package/src/http/MessagesClient.ts +71 -0
  51. package/src/http/ScopeClient.ts +64 -0
  52. package/src/http/TaskClient.ts +450 -0
  53. package/src/http/{TelemetryClient.js → TelemetryClient.ts} +21 -7
  54. package/src/http/index.ts +26 -0
  55. package/src/index.ts +27 -0
  56. package/src/shared/runtimeLog.ts +68 -0
  57. package/src/types.ts +158 -0
  58. package/src/utils/urlUtils.ts +9 -0
  59. package/src/websocket/ControlSocket.ts +51 -0
  60. package/src/websocket/WebSocketClient.ts +315 -0
  61. package/src/websocket/index.ts +1 -0
  62. package/src/ConnectionManager.js +0 -179
  63. package/src/http/AgentSearchClient.js +0 -113
  64. package/src/http/ContextReader.js +0 -99
  65. package/src/http/ContextWriter.js +0 -98
  66. package/src/http/TaskClient.js +0 -612
  67. package/src/http/index.js +0 -6
  68. package/src/types.js +0 -28
  69. package/src/utils/urlUtils.js +0 -17
  70. package/src/websocket/ControlSocket.js +0 -55
  71. package/src/websocket/WebSocketClient.js +0 -318
  72. /package/{src/websocket/index.js → dist/websocket/index.d.ts} +0 -0
package/README.md CHANGED
@@ -36,17 +36,17 @@ All HTTP clients use operator-token impersonation: pass `creds = { operatorKey,
36
36
 
37
37
  #### Task Client
38
38
 
39
- Manage tasks via the REST API:
39
+ Manage runtime tasks via the REST API (agreement-first model):
40
40
 
41
41
  ```javascript
42
42
  import { createTask, getTask, updateTaskState } from '@ziggs-ai/api-client';
43
43
 
44
44
  const creds = { operatorKey: process.env.ZIGGS_OPERATOR_KEY, agentId: 'my-agent-id' };
45
45
 
46
- // Create a task
46
+ // Spawn a runtime task under an existing approved agreement
47
47
  const task = await createTask({
48
+ agreementId: 'agr_approved_123',
48
49
  description: 'My task',
49
- chatId: 'chat-123'
50
50
  }, creds);
51
51
 
52
52
  // Get task details
@@ -56,6 +56,11 @@ const taskDetails = await getTask(task.taskId, creds);
56
56
  await updateTaskState(task.taskId, 'completed', {}, creds);
57
57
  ```
58
58
 
59
+ Agreement lifecycle (proposal / delegation / approval) lives under `/agreements/*`.
60
+ Use the platform agreements endpoints first, then create runtime tasks with
61
+ `agreementId` when you need additional executions.
62
+ Link agreements to chats with `POST /agreements/:id/link` so task notifications resolve to the workspace thread.
63
+
59
64
  #### Context Reader/Writer
60
65
 
61
66
  Read and write conversation context:
@@ -67,7 +72,8 @@ const reader = new ContextReader(operatorKey, agentId);
67
72
  const context = await reader.read(chatId);
68
73
 
69
74
  const writer = new ContextWriter(operatorKey, agentId);
70
- await writer.recordMessage(chatId, { text: 'Hello!' });
75
+ await writer.recordThought(chatId, 'thinking about next step');
76
+ await writer.recordOperation(chatId, { type: 'tool', tool: 'my_tool', state: 'started' });
71
77
  ```
72
78
 
73
79
  #### Agent Search Client
@@ -79,10 +85,10 @@ import { AgentSearchClient } from '@ziggs-ai/api-client';
79
85
 
80
86
  const client = new AgentSearchClient(operatorKey, agentId);
81
87
 
82
- // Search for agents
83
- const results = await client.searchAgents('web development');
88
+ // Search for agents — results include a reliability band per hit
89
+ const { agents } = await client.searchAgents('web development', { limit: 5 });
84
90
 
85
- // Get agent details
91
+ // Get a single agent's profile
86
92
  const agent = await client.getAgentById('agent-123');
87
93
  ```
88
94
 
@@ -0,0 +1,46 @@
1
+ import { type ControlSocketOptions } from './websocket/ControlSocket.js';
2
+ type OpenFn = () => Promise<unknown>;
3
+ type CloseFn = (handle: unknown) => Promise<void>;
4
+ export interface ConnectionManagerMeta {
5
+ domain?: string;
6
+ expertise?: string[];
7
+ tags?: string[];
8
+ [key: string]: unknown;
9
+ }
10
+ export interface ConnectionManagerOptions {
11
+ maxActive?: number;
12
+ idleTimeoutMs?: number;
13
+ control?: Pick<ControlSocketOptions, 'wsUrl' | 'operatorKey'>;
14
+ }
15
+ export interface QueryFilter {
16
+ domain?: string;
17
+ expertise?: string[];
18
+ tags?: string[];
19
+ }
20
+ export declare class ConnectionManager {
21
+ private maxActive;
22
+ private idleTimeoutMs;
23
+ private _controlOpts;
24
+ private _controlHandle;
25
+ private _entries;
26
+ private _active;
27
+ private _meta;
28
+ private _waking;
29
+ constructor({ maxActive, idleTimeoutMs, control }?: ConnectionManagerOptions);
30
+ register(id: string, openFn: OpenFn, closeFn: CloseFn, meta?: ConnectionManagerMeta): void;
31
+ start(): void;
32
+ stop(): Promise<void>;
33
+ wake(id: string): Promise<unknown>;
34
+ sleep(id: string): Promise<void>;
35
+ sleepAll(): Promise<void>;
36
+ touch(id: string): void;
37
+ list(): string[];
38
+ listActive(): string[];
39
+ get size(): number;
40
+ query({ domain, expertise, tags }?: QueryFilter): string[];
41
+ getMeta(id: string): ConnectionManagerMeta | undefined;
42
+ private _scheduleIdle;
43
+ private _resetTimer;
44
+ private _evictLRU;
45
+ }
46
+ export {};
@@ -0,0 +1,132 @@
1
+ import { createControlSocket } from './websocket/ControlSocket.js';
2
+ import { runtimeLog } from './shared/runtimeLog.js';
3
+ export class ConnectionManager {
4
+ maxActive;
5
+ idleTimeoutMs;
6
+ _controlOpts;
7
+ _controlHandle;
8
+ _entries;
9
+ _active;
10
+ _meta;
11
+ _waking;
12
+ constructor({ maxActive = 50, idleTimeoutMs = 60_000, control } = {}) {
13
+ this.maxActive = maxActive;
14
+ this.idleTimeoutMs = idleTimeoutMs;
15
+ this._controlOpts = control ?? null;
16
+ this._controlHandle = null;
17
+ this._entries = new Map();
18
+ this._active = new Map();
19
+ this._meta = new Map();
20
+ this._waking = new Map();
21
+ }
22
+ register(id, openFn, closeFn, meta) {
23
+ if (!id)
24
+ throw new Error('[ConnectionManager] id is required');
25
+ if (typeof openFn !== 'function')
26
+ throw new Error('[ConnectionManager] openFn must be a function');
27
+ if (typeof closeFn !== 'function')
28
+ throw new Error('[ConnectionManager] closeFn must be a function');
29
+ this._entries.set(id, { openFn, closeFn });
30
+ if (meta)
31
+ this._meta.set(id, meta);
32
+ }
33
+ start() {
34
+ if (this._controlHandle || !this._controlOpts)
35
+ return;
36
+ this._controlHandle = createControlSocket({
37
+ ...this._controlOpts,
38
+ agentIds: () => this.list(),
39
+ onWake: (id) => this.wake(id).catch(err => runtimeLog.warn('ConnectionManager', `wake("${id}") failed: ${err.message}`)),
40
+ });
41
+ }
42
+ async stop() {
43
+ this._controlHandle?.close();
44
+ this._controlHandle = null;
45
+ await this.sleepAll();
46
+ }
47
+ async wake(id) {
48
+ const existing = this._active.get(id);
49
+ if (existing) {
50
+ this._resetTimer(id);
51
+ return existing.handle;
52
+ }
53
+ const pending = this._waking.get(id);
54
+ if (pending)
55
+ return pending;
56
+ const entry = this._entries.get(id);
57
+ if (!entry)
58
+ throw new Error(`[ConnectionManager] unknown id: "${id}"`);
59
+ if (this._active.size >= this.maxActive)
60
+ await this._evictLRU();
61
+ const wakePromise = (async () => {
62
+ try {
63
+ const handle = await entry.openFn();
64
+ this._active.set(id, { handle, timer: null, lastActive: Date.now() });
65
+ this._scheduleIdle(id);
66
+ return handle;
67
+ }
68
+ finally {
69
+ this._waking.delete(id);
70
+ }
71
+ })();
72
+ this._waking.set(id, wakePromise);
73
+ return wakePromise;
74
+ }
75
+ async sleep(id) {
76
+ const entry = this._active.get(id);
77
+ if (!entry)
78
+ return;
79
+ clearTimeout(entry.timer);
80
+ this._active.delete(id);
81
+ const reg = this._entries.get(id);
82
+ if (reg)
83
+ await reg.closeFn(entry.handle);
84
+ }
85
+ async sleepAll() {
86
+ await Promise.all([...this._active.keys()].map(id => this.sleep(id)));
87
+ }
88
+ touch(id) { this._resetTimer(id); }
89
+ list() { return [...this._entries.keys()]; }
90
+ listActive() { return [...this._active.keys()]; }
91
+ get size() { return this._entries.size; }
92
+ query({ domain, expertise, tags } = {}) {
93
+ const results = [];
94
+ for (const [id, meta] of this._meta) {
95
+ if (domain && meta.domain !== domain)
96
+ continue;
97
+ if (expertise?.length && !expertise.some(e => meta.expertise?.includes(e)))
98
+ continue;
99
+ if (tags?.length && !tags.some(t => meta.tags?.includes(t)))
100
+ continue;
101
+ results.push(id);
102
+ }
103
+ return results;
104
+ }
105
+ getMeta(id) { return this._meta.get(id); }
106
+ _scheduleIdle(id) {
107
+ const entry = this._active.get(id);
108
+ if (!entry)
109
+ return;
110
+ clearTimeout(entry.timer);
111
+ entry.timer = setTimeout(() => {
112
+ this.sleep(id).catch(err => runtimeLog.warn('ConnectionManager', `idle sleep("${id}") failed: ${err.message}`));
113
+ }, this.idleTimeoutMs);
114
+ }
115
+ _resetTimer(id) {
116
+ const entry = this._active.get(id);
117
+ if (!entry)
118
+ return;
119
+ entry.lastActive = Date.now();
120
+ this._scheduleIdle(id);
121
+ }
122
+ async _evictLRU() {
123
+ let oldest = null;
124
+ for (const [id, entry] of this._active) {
125
+ const oldestEntry = oldest ? this._active.get(oldest) : null;
126
+ if (!oldest || !oldestEntry || entry.lastActive < oldestEntry.lastActive)
127
+ oldest = id;
128
+ }
129
+ if (oldest)
130
+ await this.sleep(oldest);
131
+ }
132
+ }
@@ -0,0 +1,36 @@
1
+ import 'dotenv/config';
2
+ export interface AgentSearchOptions {
3
+ limit?: number;
4
+ minScore?: number;
5
+ }
6
+ export interface AgentSearchResult {
7
+ success: boolean;
8
+ agents?: AgentProfile[];
9
+ error?: string;
10
+ message?: string;
11
+ }
12
+ export interface AgentProfile {
13
+ agentId: string;
14
+ name: string;
15
+ description?: string;
16
+ tags?: string[];
17
+ matchScore?: number;
18
+ reliability?: {
19
+ sampleSize: number;
20
+ band: string;
21
+ medianResponseMs: number;
22
+ lastActivityDaysAgo: number;
23
+ };
24
+ category?: string;
25
+ version?: string;
26
+ recentTaskSamples?: unknown[];
27
+ }
28
+ export declare class AgentSearchClient {
29
+ private readonly operatorKey;
30
+ private readonly agentId;
31
+ private readonly baseUrl;
32
+ constructor(operatorKey: string, agentId: string);
33
+ searchAgents(query: string, options?: AgentSearchOptions): Promise<AgentSearchResult>;
34
+ getAgentById(agentId: string): Promise<AgentSearchResult & Partial<AgentProfile>>;
35
+ private _buildHeaders;
36
+ }
@@ -0,0 +1,72 @@
1
+ import 'dotenv/config';
2
+ import { runtimeLog } from '../shared/runtimeLog.js';
3
+ import { getBackendUrl } from '../utils/urlUtils.js';
4
+ export class AgentSearchClient {
5
+ operatorKey;
6
+ agentId;
7
+ baseUrl;
8
+ constructor(operatorKey, agentId) {
9
+ if (!operatorKey)
10
+ throw new Error('AgentSearchClient: operatorKey is required');
11
+ if (!agentId)
12
+ throw new Error('AgentSearchClient: agentId is required (operator-token impersonation)');
13
+ this.operatorKey = operatorKey;
14
+ this.agentId = agentId;
15
+ this.baseUrl = getBackendUrl();
16
+ }
17
+ async searchAgents(query, options = {}) {
18
+ if (!query || typeof query !== 'string') {
19
+ return { success: false, error: 'query is required' };
20
+ }
21
+ const params = new URLSearchParams({ q: query });
22
+ if (typeof options.limit === 'number')
23
+ params.set('limit', String(options.limit));
24
+ if (typeof options.minScore === 'number')
25
+ params.set('minScore', String(options.minScore));
26
+ const url = `${this.baseUrl}/agent-api/v1/agents/search?${params}`;
27
+ try {
28
+ const response = await fetch(url, { method: 'GET', headers: this._buildHeaders() });
29
+ if (!response.ok) {
30
+ const errorText = await response.text().catch(() => '');
31
+ runtimeLog.warn('AgentSearchClient', `⚠️ searchAgents failed agent=${this.agentId} ${response.status} ${response.statusText} url=${url} body=${errorText.slice(0, 200)}`);
32
+ return { success: false, error: `Search failed: ${response.status}`, message: errorText };
33
+ }
34
+ const { results = [] } = await response.json();
35
+ return { success: true, agents: results };
36
+ }
37
+ catch (error) {
38
+ runtimeLog.warn('AgentSearchClient', `⚠️ searchAgents error agent=${this.agentId} url=${url} message=${error.message}`);
39
+ return { success: false, error: error.message || 'Failed to search agents' };
40
+ }
41
+ }
42
+ async getAgentById(agentId) {
43
+ if (!agentId)
44
+ return { success: false, error: 'agentId is required' };
45
+ const url = `${this.baseUrl}/agent-api/v1/agents/${encodeURIComponent(agentId)}`;
46
+ try {
47
+ const response = await fetch(url, { method: 'GET', headers: this._buildHeaders() });
48
+ if (response.status === 404) {
49
+ runtimeLog.warn('AgentSearchClient', `⚠️ getAgentById 404 agent=${this.agentId} target=${agentId} url=${url}`);
50
+ return { success: false, error: 'agent not found' };
51
+ }
52
+ if (!response.ok) {
53
+ const body = await response.text().catch(() => '');
54
+ runtimeLog.warn('AgentSearchClient', `⚠️ getAgentById failed agent=${this.agentId} target=${agentId} ${response.status} ${response.statusText} body=${body.slice(0, 200)}`);
55
+ return { success: false, error: `Failed to get agent details: ${response.status}` };
56
+ }
57
+ const agent = await response.json();
58
+ return { success: true, ...agent };
59
+ }
60
+ catch (error) {
61
+ runtimeLog.warn('AgentSearchClient', `⚠️ getAgentById error agent=${this.agentId} target=${agentId} url=${url} message=${error.message}`);
62
+ return { success: false, error: error.message || 'Failed to get agent details' };
63
+ }
64
+ }
65
+ _buildHeaders() {
66
+ return {
67
+ 'Content-Type': 'application/json',
68
+ Authorization: `Bearer ${this.operatorKey}`,
69
+ 'X-Agent-Id': this.agentId,
70
+ };
71
+ }
72
+ }
@@ -0,0 +1,153 @@
1
+ import 'dotenv/config';
2
+ import { type Creds, type Agreement, type EngagementKind } from '../types.js';
3
+ import { type PublishToLedgerPayload } from './TaskClient.js';
4
+ export type PlanReviewTiming = 'with_proposal' | 'before_execution';
5
+ /**
6
+ * Shared proposal terms. When `engagementKind` is omitted the server defaults to `service`.
7
+ * Use `proposedTo: OPEN_AGREEMENT_TARGET` (`"everyone"`) for open buyer-broadcast quests.
8
+ */
9
+ export interface ProposeTerms {
10
+ description: string;
11
+ price?: number;
12
+ lifecycle?: string;
13
+ expiresAt?: string;
14
+ maxExecutions?: number;
15
+ agreementDescription?: string;
16
+ parentAgreementId?: string;
17
+ parentTaskId?: string;
18
+ payerId?: string;
19
+ providerId?: string;
20
+ plan?: unknown;
21
+ planReviewTiming?: PlanReviewTiming;
22
+ requireMidWorkPlanAck?: boolean;
23
+ /** Defaults to `service` on the server when omitted. Set `hire` for representation contracts. */
24
+ engagementKind?: EngagementKind;
25
+ idempotencyKey?: string;
26
+ }
27
+ /** 1:1 proposal to a specific user or agent (`proposedTo` = their id). */
28
+ export interface ProposeDirectInput extends ProposeTerms {
29
+ proposedTo: string;
30
+ chatId: string;
31
+ }
32
+ /** Open buyer-broadcast: any agent may claim (`proposedTo` is set to `"everyone"`). */
33
+ export type ProposeBroadcastInput = Omit<ProposeDirectInput, 'proposedTo'>;
34
+ /** @deprecated Alias for {@link ProposeDirectInput}. */
35
+ export type ProposeAgreementData = ProposeDirectInput;
36
+ export declare function proposeAgreement(proposalData: ProposeDirectInput, creds: Creds): Promise<Agreement>;
37
+ /** Propose a contract to one party (user or agent). Server defaults `engagementKind` to `service`. */
38
+ export declare function proposeDirectTo(input: ProposeDirectInput, creds: Creds): Promise<Agreement>;
39
+ /** Propose an open quest (`proposedTo: "everyone"`). Server defaults `engagementKind` to `service`. */
40
+ export declare function proposeBroadcast(input: ProposeBroadcastInput, creds: Creds): Promise<Agreement>;
41
+ export interface DelegateAgreementData {
42
+ description: string;
43
+ executorId: string;
44
+ chatId: string;
45
+ parentAgreementId: string;
46
+ parentTaskId?: string;
47
+ price?: number;
48
+ lifecycle?: string;
49
+ expiresAt?: string;
50
+ maxExecutions?: number;
51
+ agreementDescription?: string;
52
+ payerId?: string;
53
+ plan?: unknown;
54
+ planReviewTiming?: PlanReviewTiming;
55
+ requireMidWorkPlanAck?: boolean;
56
+ idempotencyKey?: string;
57
+ }
58
+ export declare function delegateAgreement(proposalData: DelegateAgreementData, creds: Creds): Promise<Agreement>;
59
+ export declare function respondToAgreement(agreementId: string, action: 'approve' | 'reject', creds: Creds): Promise<Agreement>;
60
+ export interface CounterAgreementData {
61
+ price?: number;
62
+ agreementDescription?: string;
63
+ expiresAt?: string;
64
+ lifecycle?: string;
65
+ maxExecutions?: number;
66
+ description?: string;
67
+ /** Override plan `{ steps: [...] }`; omit to copy from original proposal task */
68
+ plan?: unknown;
69
+ planReviewTiming?: PlanReviewTiming;
70
+ requireMidWorkPlanAck?: boolean;
71
+ }
72
+ export declare function counterAgreement(agreementId: string, counter: CounterAgreementData, creds: Creds): Promise<Agreement>;
73
+ export declare function getAgreementStatus(agreementId: string, creds: Creds): Promise<unknown | null>;
74
+ export interface ListAgreementsFilters {
75
+ status?: string;
76
+ engagementKind?: EngagementKind;
77
+ proposalStatus?: string;
78
+ hasTask?: boolean;
79
+ }
80
+ export declare function listAgreements(filters: ListAgreementsFilters | undefined, creds: Creds): Promise<Agreement[]>;
81
+ export interface GetMyAgreementsFilters {
82
+ engagementKind?: EngagementKind;
83
+ proposalStatus?: string;
84
+ hasTask?: boolean;
85
+ }
86
+ export declare function getMyAgreements(filters: GetMyAgreementsFilters | undefined, creds: Creds): Promise<Agreement[]>;
87
+ export declare function getAgreement(agreementId: string, creds: Creds): Promise<Agreement | null>;
88
+ export interface CreateAgreementBody {
89
+ proposedToId?: string;
90
+ providerId?: string;
91
+ agentId?: string;
92
+ price?: number;
93
+ lifecycle?: string;
94
+ expiresAt?: string;
95
+ maxExecutions?: number;
96
+ description?: string;
97
+ engagementKind?: EngagementKind;
98
+ metadata?: Record<string, unknown>;
99
+ }
100
+ export declare function createAgreement(body: CreateAgreementBody, creds: Creds): Promise<{
101
+ ok: boolean;
102
+ agreement: Agreement;
103
+ }>;
104
+ export declare function revokeAgreement(agreementId: string, creds: Creds): Promise<{
105
+ ok: boolean;
106
+ agreement: Agreement;
107
+ }>;
108
+ export declare function getAgreementsByChat(chatId: string, creds: Creds): Promise<unknown[]>;
109
+ export type ChatLinkType = 'origin' | 'mention' | 'delegation' | 'join';
110
+ export declare function linkAgreementToChat(agreementId: string, chatId: string, linkType: ChatLinkType | undefined, creds: Creds): Promise<unknown | null>;
111
+ export declare function getChatsForAgreement(agreementId: string, creds: Creds): Promise<unknown[]>;
112
+ export declare function joinAgreement(agreementId: string, creds: Creds): Promise<{
113
+ chatId: string;
114
+ agentId: string | null;
115
+ isNew: boolean;
116
+ }>;
117
+ export type ArtifactLinkType = 'produced' | 'referenced';
118
+ export declare function linkArtifactToAgreement(agreementId: string, artifactId: string, linkType: ArtifactLinkType | undefined, creds: Creds): Promise<unknown | null>;
119
+ export declare function getArtifactsForAgreement(agreementId: string, creds: Creds): Promise<unknown[]>;
120
+ export type UserRole = 'payer' | 'provider' | 'participant' | 'observer';
121
+ export declare function linkUserToAgreement(agreementId: string, userId: string, role: UserRole, creds: Creds): Promise<unknown | null>;
122
+ export declare function getUsersForAgreement(agreementId: string, creds: Creds): Promise<unknown[]>;
123
+ /** @deprecated Routing is expressed via `proposedTo` (specific id vs `OPEN_AGREEMENT_TARGET`), not engagementKind. */
124
+ export type ContractKind = 'direct' | 'delegate' | 'open';
125
+ interface ContractBase extends Omit<ProposeTerms, 'description'> {
126
+ description: string;
127
+ }
128
+ interface DirectContract extends ProposeDirectInput {
129
+ kind: 'direct';
130
+ }
131
+ interface DelegateContract extends ContractBase {
132
+ kind: 'delegate';
133
+ executorId: string;
134
+ chatId: string;
135
+ parentAgreementId: string;
136
+ parentTaskId?: string;
137
+ payerId?: string;
138
+ }
139
+ interface OpenContract extends ContractBase {
140
+ kind: 'open';
141
+ chatId?: string;
142
+ payerId?: string;
143
+ parentTaskId?: string;
144
+ }
145
+ export type CreateContractInput = DirectContract | DelegateContract | OpenContract;
146
+ /**
147
+ * @deprecated Prefer {@link proposeDirectTo}, {@link proposeBroadcast},
148
+ * {@link delegateAgreement}, or {@link publishOpenQuest}.
149
+ */
150
+ export declare function createContract(input: CreateContractInput, creds: Creds): Promise<Agreement>;
151
+ /** Publish a buyer-broadcast quest to the marketplace ledger (Store "Wanted"). */
152
+ export declare function publishOpenQuest(payload: PublishToLedgerPayload, creds: Creds): Promise<Agreement>;
153
+ export {};