@ziggs-ai/contracts 0.23.2 → 0.24.0
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/dist/generated/agreements.d.ts +4 -0
- package/dist/inbox.d.ts +9 -0
- package/dist/socket.d.ts +27 -3
- package/dist/socket.js +4 -1
- package/dist/vocabulary.d.ts +96 -0
- package/dist/vocabulary.js +127 -1
- package/package.json +1 -1
|
@@ -112,6 +112,10 @@ export type AgreementRead = {
|
|
|
112
112
|
primitive?: "context";
|
|
113
113
|
kind?: "access-request" | "author-share";
|
|
114
114
|
holderId?: string;
|
|
115
|
+
holders?: Array<{
|
|
116
|
+
kind: "agent" | "user" | "org";
|
|
117
|
+
id: string;
|
|
118
|
+
}>;
|
|
115
119
|
scope?: {
|
|
116
120
|
kind: string;
|
|
117
121
|
id: string;
|
package/dist/inbox.d.ts
CHANGED
|
@@ -79,6 +79,15 @@ export interface AccessAsk {
|
|
|
79
79
|
* repeating it here would be a second answer to one question.
|
|
80
80
|
*/
|
|
81
81
|
holderDisplayName: string | null;
|
|
82
|
+
/**
|
|
83
|
+
* The readers a yes would let read it, when the agent asked for others
|
|
84
|
+
* rather than (or as well as) itself. One grant per reader. Labels only,
|
|
85
|
+
* never ids. Absent on an ask for the asking agent alone.
|
|
86
|
+
*/
|
|
87
|
+
readers?: Array<{
|
|
88
|
+
kind: 'agent' | 'user' | 'org';
|
|
89
|
+
displayName: string | null;
|
|
90
|
+
}>;
|
|
82
91
|
/** Why, in the requester's own words. */
|
|
83
92
|
reason: string | null;
|
|
84
93
|
/**
|
package/dist/socket.d.ts
CHANGED
|
@@ -68,22 +68,46 @@ export interface ChatReadFrame {
|
|
|
68
68
|
* Written as a map so a client can type one listener registry over it and be
|
|
69
69
|
* told when a frame it handles changes shape.
|
|
70
70
|
*/
|
|
71
|
+
export interface AgentLivenessFrame {
|
|
72
|
+
agentId: string;
|
|
73
|
+
state: 'online' | 'offline' | 'suspended';
|
|
74
|
+
}
|
|
75
|
+
/** The roster of a room changed. Clients re-read parties. */
|
|
76
|
+
export interface ChatParticipantsChangedFrame {
|
|
77
|
+
chatIds: string[];
|
|
78
|
+
reason?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Which messages were read. The client sends this; the server fans the same
|
|
82
|
+
* shape back out, sometimes with `kind` so a handover is not a human read.
|
|
83
|
+
*/
|
|
84
|
+
export interface ChatMessageReadFrame {
|
|
85
|
+
chatId: string;
|
|
86
|
+
messageIds: string[];
|
|
87
|
+
kind?: 'agent_handover';
|
|
88
|
+
}
|
|
71
89
|
export interface ServerToClientEvents {
|
|
72
90
|
'chat:message:new': ChatMessageNewFrame;
|
|
91
|
+
'chat:message:read': ChatMessageReadFrame;
|
|
73
92
|
'chat:read': ChatReadFrame;
|
|
93
|
+
'chat:participants_changed': ChatParticipantsChangedFrame;
|
|
94
|
+
'agent:liveness': AgentLivenessFrame;
|
|
74
95
|
resource_changed: ResourceChangedFrame;
|
|
75
96
|
}
|
|
76
|
-
/** Every frame a client sends. */
|
|
97
|
+
/** Every frame a client sends. Joining a room is not one of them. */
|
|
77
98
|
export interface ClientToServerEvents {
|
|
78
|
-
'chat:
|
|
99
|
+
'chat:message:read': ChatMessageReadFrame;
|
|
79
100
|
}
|
|
80
101
|
/** Wire names of the frames a client receives. */
|
|
81
102
|
export declare const SERVER_EVENTS: {
|
|
82
103
|
readonly chatMessageNew: "chat:message:new";
|
|
104
|
+
readonly chatMessageRead: "chat:message:read";
|
|
83
105
|
readonly chatRead: "chat:read";
|
|
106
|
+
readonly chatParticipantsChanged: "chat:participants_changed";
|
|
107
|
+
readonly agentLiveness: "agent:liveness";
|
|
84
108
|
readonly resourceChanged: "resource_changed";
|
|
85
109
|
};
|
|
86
110
|
/** Wire names of the frames a client sends. */
|
|
87
111
|
export declare const CLIENT_EVENTS: {
|
|
88
|
-
readonly
|
|
112
|
+
readonly chatMessageRead: "chat:message:read";
|
|
89
113
|
};
|
package/dist/socket.js
CHANGED
|
@@ -4,10 +4,13 @@ exports.CLIENT_EVENTS = exports.SERVER_EVENTS = void 0;
|
|
|
4
4
|
/** Wire names of the frames a client receives. */
|
|
5
5
|
exports.SERVER_EVENTS = {
|
|
6
6
|
chatMessageNew: 'chat:message:new',
|
|
7
|
+
chatMessageRead: 'chat:message:read',
|
|
7
8
|
chatRead: 'chat:read',
|
|
9
|
+
chatParticipantsChanged: 'chat:participants_changed',
|
|
10
|
+
agentLiveness: 'agent:liveness',
|
|
8
11
|
resourceChanged: 'resource_changed',
|
|
9
12
|
};
|
|
10
13
|
/** Wire names of the frames a client sends. */
|
|
11
14
|
exports.CLIENT_EVENTS = {
|
|
12
|
-
|
|
15
|
+
chatMessageRead: 'chat:message:read',
|
|
13
16
|
};
|
package/dist/vocabulary.d.ts
CHANGED
|
@@ -63,3 +63,99 @@ export declare const ARTIFACT_FILE_FORMAT: {
|
|
|
63
63
|
export type ArtifactFileFormat = (typeof ARTIFACT_FILE_FORMAT)[keyof typeof ARTIFACT_FILE_FORMAT];
|
|
64
64
|
/** Every accepted format, in one list. */
|
|
65
65
|
export declare const ARTIFACT_FILE_FORMATS: readonly ArtifactFileFormat[];
|
|
66
|
+
/** The four sides of an agreement, in the order every fan-out walks them. */
|
|
67
|
+
export declare const AGREEMENT_PARTY_SIDES: readonly ["payer", "provider", "proposedTo", "creator"];
|
|
68
|
+
export type AgreementPartySideName = (typeof AGREEMENT_PARTY_SIDES)[number];
|
|
69
|
+
/**
|
|
70
|
+
* A party slot that is a broadcast, not a person.
|
|
71
|
+
* `everyone` is public. `org` is the agreement's company only.
|
|
72
|
+
*/
|
|
73
|
+
export declare const OPEN_AGREEMENT_TARGET = "everyone";
|
|
74
|
+
export declare const ORG_AGREEMENT_TARGET = "org";
|
|
75
|
+
export declare const BROADCAST_TARGETS: readonly ["everyone", "org"];
|
|
76
|
+
export type BroadcastAudience = (typeof BROADCAST_TARGETS)[number];
|
|
77
|
+
export declare function isBroadcastTarget(id: string | null | undefined): id is BroadcastAudience;
|
|
78
|
+
/** One side, as ids only. Callers may pass the stored row. */
|
|
79
|
+
export interface PartySideRef {
|
|
80
|
+
principal?: string | null;
|
|
81
|
+
actor?: string | null;
|
|
82
|
+
}
|
|
83
|
+
/** Both ids on a side, principal then actor, blanks dropped. */
|
|
84
|
+
export declare function partySideIds(side: PartySideRef | null | undefined): string[];
|
|
85
|
+
/** The agents that acted on any side, deduped. */
|
|
86
|
+
export declare function partyActorIds(parties: Partial<Record<AgreementPartySideName, PartySideRef | null>> | null | undefined): string[];
|
|
87
|
+
/** What kind of agreement this paper is. A link is reach, not a hire. */
|
|
88
|
+
export declare const AGREEMENT_ENGAGEMENT_KIND: {
|
|
89
|
+
readonly HIRE: "hire";
|
|
90
|
+
readonly SERVICE: "service";
|
|
91
|
+
readonly LINK: "link";
|
|
92
|
+
};
|
|
93
|
+
export type AgreementEngagementKind = (typeof AGREEMENT_ENGAGEMENT_KIND)[keyof typeof AGREEMENT_ENGAGEMENT_KIND];
|
|
94
|
+
/**
|
|
95
|
+
* A seller's standing offer: the payer slot is a broadcast, and the paper
|
|
96
|
+
* is not a reach link. Any status — a paused listing is still a listing.
|
|
97
|
+
*/
|
|
98
|
+
export declare function isSellerListing(row: {
|
|
99
|
+
engagementKind?: string | null;
|
|
100
|
+
parties?: {
|
|
101
|
+
payer?: {
|
|
102
|
+
principal?: string | null;
|
|
103
|
+
} | null;
|
|
104
|
+
} | null;
|
|
105
|
+
} | null | undefined): boolean;
|
|
106
|
+
/** A task is born active. Negotiation lives on the agreement, not here. */
|
|
107
|
+
export declare const TASK_STATE: {
|
|
108
|
+
readonly ACTIVE: "active";
|
|
109
|
+
readonly COMPLETED: "completed";
|
|
110
|
+
readonly FAILED: "failed";
|
|
111
|
+
readonly CANCELLED: "cancelled";
|
|
112
|
+
};
|
|
113
|
+
export type TaskStateValue = (typeof TASK_STATE)[keyof typeof TASK_STATE];
|
|
114
|
+
export declare const TASK_STATES: readonly TaskStateValue[];
|
|
115
|
+
/** Finished: nothing left to run. */
|
|
116
|
+
export declare const TERMINAL_TASK_STATES: readonly TaskStateValue[];
|
|
117
|
+
export declare function isTerminalTaskState(state: string): boolean;
|
|
118
|
+
export declare const AGREEMENT_STATUS: {
|
|
119
|
+
readonly DRAFT: "draft";
|
|
120
|
+
readonly OPEN: "open";
|
|
121
|
+
readonly ACTIVE: "active";
|
|
122
|
+
readonly FULFILLED: "fulfilled";
|
|
123
|
+
readonly CANCELLED: "cancelled";
|
|
124
|
+
readonly REFUNDED: "refunded";
|
|
125
|
+
};
|
|
126
|
+
export type AgreementStatusValue = (typeof AGREEMENT_STATUS)[keyof typeof AGREEMENT_STATUS];
|
|
127
|
+
export declare const AGREEMENT_STATUSES: readonly AgreementStatusValue[];
|
|
128
|
+
export declare const AGREEMENT_TERMINAL_STATES: readonly AgreementStatusValue[];
|
|
129
|
+
/**
|
|
130
|
+
* Context-rail scopes, then the other rails a grant can name.
|
|
131
|
+
* Order is the order the grants read and the OpenAPI enum publish.
|
|
132
|
+
*/
|
|
133
|
+
export declare const CONTEXT_GRANT_SCOPE_KINDS: readonly ["chat", "agreement", "org", "artifact", "task"];
|
|
134
|
+
export declare const GRANT_SCOPE_KINDS: readonly ["chat", "agreement", "org", "artifact", "task", "connection", "wallet", "consent", "inbox"];
|
|
135
|
+
export type GrantScopeKind = (typeof GRANT_SCOPE_KINDS)[number];
|
|
136
|
+
export type ContextGrantScopeKind = (typeof CONTEXT_GRANT_SCOPE_KINDS)[number];
|
|
137
|
+
/** What an access request may name. Always one resource. */
|
|
138
|
+
export declare const ACCESS_REQUEST_SCOPE_KINDS: readonly ["artifact", "chat", "agreement", "task"];
|
|
139
|
+
export type AccessRequestScopeKind = (typeof ACCESS_REQUEST_SCOPE_KINDS)[number];
|
|
140
|
+
/**
|
|
141
|
+
* Who an artifact access request may ask a grant FOR. Each reader is named
|
|
142
|
+
* with its kind; the kind is never inferred from an id or a display name.
|
|
143
|
+
*/
|
|
144
|
+
export declare const ACCESS_REQUEST_HOLDER_KINDS: readonly ["agent", "user", "org"];
|
|
145
|
+
export type AccessRequestHolderKind = (typeof ACCESS_REQUEST_HOLDER_KINDS)[number];
|
|
146
|
+
/** How many readers one access request may name. */
|
|
147
|
+
export declare const MAX_ACCESS_REQUEST_HOLDERS = 20;
|
|
148
|
+
/** What a chat entry's contentType may be. */
|
|
149
|
+
export declare const MESSAGE_CONTENT_TYPE: {
|
|
150
|
+
readonly TEXT: "text";
|
|
151
|
+
readonly OPERATION: "operation";
|
|
152
|
+
readonly CONTEXT: "context";
|
|
153
|
+
readonly RESULT: "result";
|
|
154
|
+
readonly AGREEMENT_UPDATE: "agreement_update";
|
|
155
|
+
readonly TASK: "task";
|
|
156
|
+
readonly TASK_PLAN_STEP: "task_plan_step";
|
|
157
|
+
readonly THOUGHT: "thought";
|
|
158
|
+
readonly PROPOSAL: "proposal";
|
|
159
|
+
};
|
|
160
|
+
export type MessageContentType = (typeof MESSAGE_CONTENT_TYPE)[keyof typeof MESSAGE_CONTENT_TYPE];
|
|
161
|
+
export declare const MESSAGE_CONTENT_TYPES: readonly MessageContentType[];
|
package/dist/vocabulary.js
CHANGED
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
* enum, a switch a consumer needs to make exhaustive.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.ARTIFACT_FILE_FORMATS = exports.ARTIFACT_FILE_FORMAT = exports.RESOURCE_KINDS = exports.CHAT_ADDRESS_KINDS = exports.GRANT_ACCESS_KINDS = void 0;
|
|
10
|
+
exports.MESSAGE_CONTENT_TYPES = exports.MESSAGE_CONTENT_TYPE = exports.MAX_ACCESS_REQUEST_HOLDERS = exports.ACCESS_REQUEST_HOLDER_KINDS = exports.ACCESS_REQUEST_SCOPE_KINDS = exports.GRANT_SCOPE_KINDS = exports.CONTEXT_GRANT_SCOPE_KINDS = exports.AGREEMENT_TERMINAL_STATES = exports.AGREEMENT_STATUSES = exports.AGREEMENT_STATUS = exports.TERMINAL_TASK_STATES = exports.TASK_STATES = exports.TASK_STATE = exports.AGREEMENT_ENGAGEMENT_KIND = exports.BROADCAST_TARGETS = exports.ORG_AGREEMENT_TARGET = exports.OPEN_AGREEMENT_TARGET = exports.AGREEMENT_PARTY_SIDES = exports.ARTIFACT_FILE_FORMATS = exports.ARTIFACT_FILE_FORMAT = exports.RESOURCE_KINDS = exports.CHAT_ADDRESS_KINDS = exports.GRANT_ACCESS_KINDS = void 0;
|
|
11
|
+
exports.isBroadcastTarget = isBroadcastTarget;
|
|
12
|
+
exports.partySideIds = partySideIds;
|
|
13
|
+
exports.partyActorIds = partyActorIds;
|
|
14
|
+
exports.isSellerListing = isSellerListing;
|
|
15
|
+
exports.isTerminalTaskState = isTerminalTaskState;
|
|
11
16
|
/**
|
|
12
17
|
* What a grant lets its holder do with the scope.
|
|
13
18
|
*
|
|
@@ -56,3 +61,124 @@ exports.ARTIFACT_FILE_FORMAT = {
|
|
|
56
61
|
};
|
|
57
62
|
/** Every accepted format, in one list. */
|
|
58
63
|
exports.ARTIFACT_FILE_FORMATS = Object.values(exports.ARTIFACT_FILE_FORMAT);
|
|
64
|
+
/** The four sides of an agreement, in the order every fan-out walks them. */
|
|
65
|
+
exports.AGREEMENT_PARTY_SIDES = [
|
|
66
|
+
'payer',
|
|
67
|
+
'provider',
|
|
68
|
+
'proposedTo',
|
|
69
|
+
'creator',
|
|
70
|
+
];
|
|
71
|
+
/**
|
|
72
|
+
* A party slot that is a broadcast, not a person.
|
|
73
|
+
* `everyone` is public. `org` is the agreement's company only.
|
|
74
|
+
*/
|
|
75
|
+
exports.OPEN_AGREEMENT_TARGET = 'everyone';
|
|
76
|
+
exports.ORG_AGREEMENT_TARGET = 'org';
|
|
77
|
+
exports.BROADCAST_TARGETS = [
|
|
78
|
+
exports.OPEN_AGREEMENT_TARGET,
|
|
79
|
+
exports.ORG_AGREEMENT_TARGET,
|
|
80
|
+
];
|
|
81
|
+
function isBroadcastTarget(id) {
|
|
82
|
+
return exports.BROADCAST_TARGETS.includes(id ?? '');
|
|
83
|
+
}
|
|
84
|
+
/** Both ids on a side, principal then actor, blanks dropped. */
|
|
85
|
+
function partySideIds(side) {
|
|
86
|
+
return [side?.principal, side?.actor].filter((id) => typeof id === 'string' && id.length > 0);
|
|
87
|
+
}
|
|
88
|
+
/** The agents that acted on any side, deduped. */
|
|
89
|
+
function partyActorIds(parties) {
|
|
90
|
+
const p = parties ?? {};
|
|
91
|
+
return [
|
|
92
|
+
...new Set(exports.AGREEMENT_PARTY_SIDES.map((name) => p[name]?.actor).filter((id) => !!id)),
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
/** What kind of agreement this paper is. A link is reach, not a hire. */
|
|
96
|
+
exports.AGREEMENT_ENGAGEMENT_KIND = {
|
|
97
|
+
HIRE: 'hire',
|
|
98
|
+
SERVICE: 'service',
|
|
99
|
+
LINK: 'link',
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* A seller's standing offer: the payer slot is a broadcast, and the paper
|
|
103
|
+
* is not a reach link. Any status — a paused listing is still a listing.
|
|
104
|
+
*/
|
|
105
|
+
function isSellerListing(row) {
|
|
106
|
+
return (isBroadcastTarget(row?.parties?.payer?.principal) &&
|
|
107
|
+
row?.engagementKind !== exports.AGREEMENT_ENGAGEMENT_KIND.LINK);
|
|
108
|
+
}
|
|
109
|
+
/** A task is born active. Negotiation lives on the agreement, not here. */
|
|
110
|
+
exports.TASK_STATE = {
|
|
111
|
+
ACTIVE: 'active',
|
|
112
|
+
COMPLETED: 'completed',
|
|
113
|
+
FAILED: 'failed',
|
|
114
|
+
CANCELLED: 'cancelled',
|
|
115
|
+
};
|
|
116
|
+
exports.TASK_STATES = Object.values(exports.TASK_STATE);
|
|
117
|
+
/** Finished: nothing left to run. */
|
|
118
|
+
exports.TERMINAL_TASK_STATES = [
|
|
119
|
+
exports.TASK_STATE.COMPLETED,
|
|
120
|
+
exports.TASK_STATE.FAILED,
|
|
121
|
+
exports.TASK_STATE.CANCELLED,
|
|
122
|
+
];
|
|
123
|
+
function isTerminalTaskState(state) {
|
|
124
|
+
return exports.TERMINAL_TASK_STATES.includes(state);
|
|
125
|
+
}
|
|
126
|
+
exports.AGREEMENT_STATUS = {
|
|
127
|
+
DRAFT: 'draft',
|
|
128
|
+
OPEN: 'open',
|
|
129
|
+
ACTIVE: 'active',
|
|
130
|
+
FULFILLED: 'fulfilled',
|
|
131
|
+
CANCELLED: 'cancelled',
|
|
132
|
+
REFUNDED: 'refunded',
|
|
133
|
+
};
|
|
134
|
+
exports.AGREEMENT_STATUSES = Object.values(exports.AGREEMENT_STATUS);
|
|
135
|
+
exports.AGREEMENT_TERMINAL_STATES = [
|
|
136
|
+
exports.AGREEMENT_STATUS.FULFILLED,
|
|
137
|
+
exports.AGREEMENT_STATUS.CANCELLED,
|
|
138
|
+
exports.AGREEMENT_STATUS.REFUNDED,
|
|
139
|
+
];
|
|
140
|
+
/**
|
|
141
|
+
* Context-rail scopes, then the other rails a grant can name.
|
|
142
|
+
* Order is the order the grants read and the OpenAPI enum publish.
|
|
143
|
+
*/
|
|
144
|
+
exports.CONTEXT_GRANT_SCOPE_KINDS = [
|
|
145
|
+
'chat',
|
|
146
|
+
'agreement',
|
|
147
|
+
'org',
|
|
148
|
+
'artifact',
|
|
149
|
+
'task',
|
|
150
|
+
];
|
|
151
|
+
exports.GRANT_SCOPE_KINDS = [
|
|
152
|
+
...exports.CONTEXT_GRANT_SCOPE_KINDS,
|
|
153
|
+
'connection',
|
|
154
|
+
'wallet',
|
|
155
|
+
'consent',
|
|
156
|
+
'inbox',
|
|
157
|
+
];
|
|
158
|
+
/** What an access request may name. Always one resource. */
|
|
159
|
+
exports.ACCESS_REQUEST_SCOPE_KINDS = [
|
|
160
|
+
'artifact',
|
|
161
|
+
'chat',
|
|
162
|
+
'agreement',
|
|
163
|
+
'task',
|
|
164
|
+
];
|
|
165
|
+
/**
|
|
166
|
+
* Who an artifact access request may ask a grant FOR. Each reader is named
|
|
167
|
+
* with its kind; the kind is never inferred from an id or a display name.
|
|
168
|
+
*/
|
|
169
|
+
exports.ACCESS_REQUEST_HOLDER_KINDS = ['agent', 'user', 'org'];
|
|
170
|
+
/** How many readers one access request may name. */
|
|
171
|
+
exports.MAX_ACCESS_REQUEST_HOLDERS = 20;
|
|
172
|
+
/** What a chat entry's contentType may be. */
|
|
173
|
+
exports.MESSAGE_CONTENT_TYPE = {
|
|
174
|
+
TEXT: 'text',
|
|
175
|
+
OPERATION: 'operation',
|
|
176
|
+
CONTEXT: 'context',
|
|
177
|
+
RESULT: 'result',
|
|
178
|
+
AGREEMENT_UPDATE: 'agreement_update',
|
|
179
|
+
TASK: 'task',
|
|
180
|
+
TASK_PLAN_STEP: 'task_plan_step',
|
|
181
|
+
THOUGHT: 'thought',
|
|
182
|
+
PROPOSAL: 'proposal',
|
|
183
|
+
};
|
|
184
|
+
exports.MESSAGE_CONTENT_TYPES = Object.values(exports.MESSAGE_CONTENT_TYPE);
|
package/package.json
CHANGED