@ziggs-ai/api-client 0.6.0 → 0.6.1

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.
@@ -36,6 +36,22 @@ export interface WriteArtifactInput {
36
36
  * writes. `visibility: 'agent-private'` is the new home for agent thoughts —
37
37
  * they persist, are searchable, but are not visible to other chat parties.
38
38
  */
39
+ /**
40
+ * ZIG-1032 — turn a runtime lane id into a scope the backend can accept.
41
+ *
42
+ * A task with no origin chat runs on the lane `agrn-<agreementId>` (see
43
+ * AgentHost.laneSessionIdForTask). That is a routing key, not a chat: no such
44
+ * chat row exists, so passing it as `chatId` made every breadcrumb and recorded
45
+ * thought on an agreement lane come back 403 "not authorized for this scope" —
46
+ * a fictional scope reading like an auth failure. The work is agreement-scoped,
47
+ * so say so; same rule ZIG-924 settled for deliverables.
48
+ */
49
+ export declare const AGREEMENT_LANE_PREFIX = "agrn-";
50
+ export declare function artifactScopeForSession(sessionId: string): {
51
+ chatId: string;
52
+ } | {
53
+ agreementId: string;
54
+ };
39
55
  export declare class ArtifactsClient {
40
56
  private readonly operatorKey;
41
57
  private readonly agentId?;
@@ -54,7 +70,7 @@ export declare class ArtifactsClient {
54
70
  * endpoint is updated to accept `visibility`, this falls back to logging
55
71
  * locally (operators can still wire their own sink).
56
72
  */
57
- recordThought(chatId: string, text: string, opts?: {
73
+ recordThought(sessionId: string, text: string, opts?: {
58
74
  idempotencyKey?: string;
59
75
  }): Promise<void>;
60
76
  write(input: WriteArtifactInput): Promise<void>;
@@ -7,6 +7,23 @@ import { buildOperatorHeaders } from './operatorHeaders.js';
7
7
  * writes. `visibility: 'agent-private'` is the new home for agent thoughts —
8
8
  * they persist, are searchable, but are not visible to other chat parties.
9
9
  */
10
+ /**
11
+ * ZIG-1032 — turn a runtime lane id into a scope the backend can accept.
12
+ *
13
+ * A task with no origin chat runs on the lane `agrn-<agreementId>` (see
14
+ * AgentHost.laneSessionIdForTask). That is a routing key, not a chat: no such
15
+ * chat row exists, so passing it as `chatId` made every breadcrumb and recorded
16
+ * thought on an agreement lane come back 403 "not authorized for this scope" —
17
+ * a fictional scope reading like an auth failure. The work is agreement-scoped,
18
+ * so say so; same rule ZIG-924 settled for deliverables.
19
+ */
20
+ export const AGREEMENT_LANE_PREFIX = 'agrn-';
21
+ export function artifactScopeForSession(sessionId) {
22
+ if (sessionId.startsWith(AGREEMENT_LANE_PREFIX)) {
23
+ return { agreementId: sessionId.slice(AGREEMENT_LANE_PREFIX.length) };
24
+ }
25
+ return { chatId: sessionId };
26
+ }
10
27
  export class ArtifactsClient {
11
28
  operatorKey;
12
29
  agentId;
@@ -49,9 +66,10 @@ export class ArtifactsClient {
49
66
  * endpoint is updated to accept `visibility`, this falls back to logging
50
67
  * locally (operators can still wire their own sink).
51
68
  */
52
- async recordThought(chatId, text, opts = {}) {
69
+ async recordThought(sessionId, text, opts = {}) {
70
+ // ZIG-1032: `sessionId` may be an agreement lane, which is not a chat.
53
71
  return this.write({
54
- chatId,
72
+ ...artifactScopeForSession(sessionId),
55
73
  text,
56
74
  content_type: 'thought',
57
75
  visibility: 'agent-private',
@@ -5,7 +5,7 @@ export * from './agreementFlows.js';
5
5
  export * from './ChatClient.js';
6
6
  export { MessagesClient } from './MessagesClient.js';
7
7
  export type { ListMessagesOptions, ListMessagesResult } from './MessagesClient.js';
8
- export { ArtifactsClient } from './ArtifactsClient.js';
8
+ export { ArtifactsClient, artifactScopeForSession, AGREEMENT_LANE_PREFIX, } from './ArtifactsClient.js';
9
9
  export type { ArtifactVisibility, ListArtifactsOptions, ListArtifactsQuery, ListArtifactsResult, WriteArtifactInput, } from './ArtifactsClient.js';
10
10
  export { ContextReadClient } from './ContextReadClient.js';
11
11
  export type { ContextReadType, ContextReadQuery, ContextReadEnvelope, ContextSnapshotResult, } from './ContextReadClient.js';
@@ -4,7 +4,9 @@ export * from './MarketplaceClient.js';
4
4
  export * from './agreementFlows.js';
5
5
  export * from './ChatClient.js';
6
6
  export { MessagesClient } from './MessagesClient.js';
7
- export { ArtifactsClient } from './ArtifactsClient.js';
7
+ export { ArtifactsClient,
8
+ // ZIG-1032: agreement lanes are not chats — callers scope artifact writes with this.
9
+ artifactScopeForSession, AGREEMENT_LANE_PREFIX, } from './ArtifactsClient.js';
8
10
  export { ContextReadClient } from './ContextReadClient.js';
9
11
  export { ContextDiscoveryClient } from './ContextDiscoveryClient.js';
10
12
  export { GrantsClient } from './GrantsClient.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "HTTP and WebSocket client for the Ziggs backend API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",