@sogni-ai/sogni-client 5.2.0 → 5.3.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.
- package/CHANGELOG.md +15 -0
- package/README.md +37 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.d.ts +2 -1
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +2 -2
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -1
- package/dist/ApiClient/WebSocketClient/index.d.ts +3 -1
- package/dist/ApiClient/WebSocketClient/index.js +4 -1
- package/dist/ApiClient/WebSocketClient/index.js.map +1 -1
- package/dist/ApiClient/index.d.ts +10 -1
- package/dist/ApiClient/index.js +16 -3
- package/dist/ApiClient/index.js.map +1 -1
- package/dist/ApiGroup.d.ts +3 -0
- package/dist/ApiGroup.js +13 -0
- package/dist/ApiGroup.js.map +1 -1
- package/dist/Chat/ChatTools.js +2 -1
- package/dist/Chat/ChatTools.js.map +1 -1
- package/dist/Chat/_hostedToolsManifest.generated.js +16 -10
- package/dist/Chat/_hostedToolsManifest.generated.js.map +1 -1
- package/dist/Chat/index.d.ts +6 -0
- package/dist/Chat/index.js +35 -8
- package/dist/Chat/index.js.map +1 -1
- package/dist/Chat/types.d.ts +10 -1
- package/dist/CreativeWorkflows/index.js +4 -5
- package/dist/CreativeWorkflows/index.js.map +1 -1
- package/dist/CreativeWorkflows/types.d.ts +7 -0
- package/dist/Projects/createJobRequestMessage.js +3 -1
- package/dist/Projects/createJobRequestMessage.js.map +1 -1
- package/dist/Projects/index.js +1 -1
- package/dist/Projects/index.js.map +1 -1
- package/dist/Projects/types/index.d.ts +6 -0
- package/dist/Projects/types/index.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/RestClient.d.ts +3 -2
- package/dist/lib/RestClient.js +2 -3
- package/dist/lib/RestClient.js.map +1 -1
- package/dist/lib/attribution.d.ts +24 -0
- package/dist/lib/attribution.js +264 -0
- package/dist/lib/attribution.js.map +1 -0
- package/dist/types/attribution.d.ts +67 -0
- package/dist/types/attribution.js +3 -0
- package/dist/types/attribution.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist-esm/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +2 -2
- package/dist-esm/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -1
- package/dist-esm/ApiClient/WebSocketClient/index.js +4 -1
- package/dist-esm/ApiClient/WebSocketClient/index.js.map +1 -1
- package/dist-esm/ApiClient/index.js +16 -3
- package/dist-esm/ApiClient/index.js.map +1 -1
- package/dist-esm/ApiGroup.js +13 -0
- package/dist-esm/ApiGroup.js.map +1 -1
- package/dist-esm/Chat/ChatTools.js +2 -1
- package/dist-esm/Chat/ChatTools.js.map +1 -1
- package/dist-esm/Chat/_hostedToolsManifest.generated.js +16 -10
- package/dist-esm/Chat/_hostedToolsManifest.generated.js.map +1 -1
- package/dist-esm/Chat/index.js +35 -8
- package/dist-esm/Chat/index.js.map +1 -1
- package/dist-esm/CreativeWorkflows/index.js +4 -5
- package/dist-esm/CreativeWorkflows/index.js.map +1 -1
- package/dist-esm/Projects/createJobRequestMessage.js +3 -1
- package/dist-esm/Projects/createJobRequestMessage.js.map +1 -1
- package/dist-esm/Projects/index.js +1 -1
- package/dist-esm/Projects/index.js.map +1 -1
- package/dist-esm/Projects/types/index.js.map +1 -1
- package/dist-esm/index.js +1 -0
- package/dist-esm/index.js.map +1 -1
- package/dist-esm/lib/RestClient.js +2 -3
- package/dist-esm/lib/RestClient.js.map +1 -1
- package/dist-esm/lib/attribution.js +257 -0
- package/dist-esm/lib/attribution.js.map +1 -0
- package/dist-esm/types/attribution.js +2 -0
- package/dist-esm/types/attribution.js.map +1 -0
- package/dist-esm/version.js +1 -1
- package/llms-full.txt +27 -0
- package/llms.txt +4 -0
- package/package.json +3 -2
- package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/index.ts +5 -2
- package/src/ApiClient/WebSocketClient/index.ts +10 -1
- package/src/ApiClient/index.ts +42 -2
- package/src/ApiGroup.ts +25 -0
- package/src/Chat/ChatTools.ts +5 -1
- package/src/Chat/_hostedToolsManifest.generated.ts +16 -10
- package/src/Chat/index.ts +46 -7
- package/src/Chat/types.ts +10 -1
- package/src/CreativeWorkflows/index.ts +11 -3
- package/src/CreativeWorkflows/types.ts +7 -0
- package/src/Projects/createJobRequestMessage.ts +4 -1
- package/src/Projects/index.ts +2 -1
- package/src/Projects/types/index.ts +6 -0
- package/src/index.ts +35 -1
- package/src/lib/RestClient.ts +10 -3
- package/src/lib/attribution.ts +304 -0
- package/src/types/attribution.ts +89 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RestClient.js","sourceRoot":"","sources":["../../src/lib/RestClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,uBAAuB,CAAC;AACnE,OAAO,iBAA+B,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"RestClient.js","sourceRoot":"","sources":["../../src/lib/RestClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,uBAAuB,CAAC;AACnE,OAAO,iBAA+B,MAAM,wBAAwB,CAAC;AAcrE,MAAM,UAAuC,SAAQ,iBAAoB;IAKvE,YAAY,OAAe,EAAE,IAAiB,EAAE,MAAc;QAC5D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEO,SAAS,CAAC,WAAmB,EAAE,Q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|
+
const VERSION_PATTERN = /^[0-9][0-9A-Za-z.+_-]*$/;
|
|
6
|
+
const OPERATION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]*$/;
|
|
7
|
+
const INTERACTION_KINDS = new Set([
|
|
8
|
+
'human_ui',
|
|
9
|
+
'external_agent',
|
|
10
|
+
'service',
|
|
11
|
+
'unknown'
|
|
12
|
+
]);
|
|
13
|
+
const WORKLOAD_KINDS = new Set(['direct', 'agent_mediated', 'service', 'unknown']);
|
|
14
|
+
const OPERATION_SCOPES = new Set(['top_level', 'child', 'unknown']);
|
|
15
|
+
const AGENT_SURFACES = new Set([
|
|
16
|
+
'native_web',
|
|
17
|
+
'native_mobile',
|
|
18
|
+
'native_desktop',
|
|
19
|
+
'plugin',
|
|
20
|
+
'personal_skill',
|
|
21
|
+
'mcp',
|
|
22
|
+
'cli',
|
|
23
|
+
'sdk',
|
|
24
|
+
'openai_compatible',
|
|
25
|
+
'direct_api',
|
|
26
|
+
'unknown'
|
|
27
|
+
]);
|
|
28
|
+
const EXECUTION_MODES = new Set(['browser', 'durable', 'server', 'unknown']);
|
|
29
|
+
function normalizeEnum(value, allowed) {
|
|
30
|
+
if (typeof value !== 'string')
|
|
31
|
+
return undefined;
|
|
32
|
+
const normalized = value.trim();
|
|
33
|
+
return allowed.has(normalized) ? normalized : undefined;
|
|
34
|
+
}
|
|
35
|
+
function normalizeBoundedString(value, maxLength) {
|
|
36
|
+
if (typeof value !== 'string')
|
|
37
|
+
return undefined;
|
|
38
|
+
const normalized = value.trim();
|
|
39
|
+
if (normalized.length === 0 ||
|
|
40
|
+
normalized.length > maxLength ||
|
|
41
|
+
UNSAFE_HEADER_CHARACTER.test(normalized)) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return normalized;
|
|
45
|
+
}
|
|
46
|
+
function normalizeVersion(value) {
|
|
47
|
+
const normalized = normalizeBoundedString(value, MAX_VERSION_LENGTH);
|
|
48
|
+
return normalized && VERSION_PATTERN.test(normalized) ? normalized : undefined;
|
|
49
|
+
}
|
|
50
|
+
function normalizeOperationId(value) {
|
|
51
|
+
if (typeof value !== 'string' ||
|
|
52
|
+
value.length === 0 ||
|
|
53
|
+
value.length > MAX_OPERATION_ID_LENGTH ||
|
|
54
|
+
value.trim() !== value ||
|
|
55
|
+
UNSAFE_HEADER_CHARACTER.test(value) ||
|
|
56
|
+
!OPERATION_ID_PATTERN.test(value)) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
function normalizeAgentMetadata(input) {
|
|
62
|
+
if (!input || typeof input !== 'object')
|
|
63
|
+
return {};
|
|
64
|
+
const result = {};
|
|
65
|
+
const agentFramework = normalizeBoundedString(input.agentFramework, MAX_METADATA_LENGTH);
|
|
66
|
+
const agentFrameworkVersion = normalizeVersion(input.agentFrameworkVersion);
|
|
67
|
+
const agentSurface = normalizeEnum(input.agentSurface, AGENT_SURFACES);
|
|
68
|
+
const agentSurfaceVersion = normalizeVersion(input.agentSurfaceVersion);
|
|
69
|
+
const executionMode = normalizeEnum(input.executionMode, EXECUTION_MODES);
|
|
70
|
+
if (agentFramework)
|
|
71
|
+
result.agentFramework = agentFramework;
|
|
72
|
+
if (agentFrameworkVersion)
|
|
73
|
+
result.agentFrameworkVersion = agentFrameworkVersion;
|
|
74
|
+
if (agentSurface)
|
|
75
|
+
result.agentSurface = agentSurface;
|
|
76
|
+
if (agentSurfaceVersion)
|
|
77
|
+
result.agentSurfaceVersion = agentSurfaceVersion;
|
|
78
|
+
if (executionMode)
|
|
79
|
+
result.executionMode = executionMode;
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
function mergeDefined(defaults, overrides) {
|
|
83
|
+
const merged = Object.assign({}, (defaults !== null && defaults !== void 0 ? defaults : {}));
|
|
84
|
+
if (overrides && typeof overrides === 'object') {
|
|
85
|
+
const defaultValues = (defaults !== null && defaults !== void 0 ? defaults : {});
|
|
86
|
+
const overrideValues = overrides;
|
|
87
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
88
|
+
if (value !== undefined)
|
|
89
|
+
merged[key] = value;
|
|
90
|
+
}
|
|
91
|
+
// A version belongs to its framework/surface. Do not accidentally retain
|
|
92
|
+
// one default's version when a request changes the corresponding identity.
|
|
93
|
+
if (overrideValues.agentFramework !== undefined &&
|
|
94
|
+
overrideValues.agentFramework !== defaultValues.agentFramework &&
|
|
95
|
+
overrideValues.agentFrameworkVersion === undefined) {
|
|
96
|
+
delete merged.agentFrameworkVersion;
|
|
97
|
+
}
|
|
98
|
+
if (overrideValues.agentSurface !== undefined &&
|
|
99
|
+
overrideValues.agentSurface !== defaultValues.agentSurface &&
|
|
100
|
+
overrideValues.agentSurfaceVersion === undefined) {
|
|
101
|
+
delete merged.agentSurfaceVersion;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return merged;
|
|
105
|
+
}
|
|
106
|
+
function hasValues(value) {
|
|
107
|
+
return Object.keys(value).length > 0;
|
|
108
|
+
}
|
|
109
|
+
export function normalizeConnectionAttribution(input) {
|
|
110
|
+
if (!input || typeof input !== 'object')
|
|
111
|
+
return undefined;
|
|
112
|
+
const result = normalizeAgentMetadata(input);
|
|
113
|
+
const interactionKind = normalizeEnum(input.interactionKind, INTERACTION_KINDS);
|
|
114
|
+
if (interactionKind)
|
|
115
|
+
result.interactionKind = interactionKind;
|
|
116
|
+
return hasValues(result) ? result : undefined;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Merge immutable client defaults with one operation's overrides and add
|
|
120
|
+
* lineage derived from the underlying request ID. Invalid runtime values are
|
|
121
|
+
* dropped instead of rejecting an otherwise valid inference request.
|
|
122
|
+
*/
|
|
123
|
+
export function resolveWorkloadAttribution(defaults, overrides, fallbackOperationId) {
|
|
124
|
+
if (!defaults && !overrides)
|
|
125
|
+
return undefined;
|
|
126
|
+
const merged = mergeDefined(defaults, overrides);
|
|
127
|
+
const result = normalizeAgentMetadata(merged);
|
|
128
|
+
const workloadKind = normalizeEnum(merged.workloadKind, WORKLOAD_KINDS);
|
|
129
|
+
const operationScope = normalizeEnum(merged.operationScope, OPERATION_SCOPES);
|
|
130
|
+
const operationId = normalizeOperationId(merged.operationId);
|
|
131
|
+
const rootOperationId = normalizeOperationId(merged.rootOperationId);
|
|
132
|
+
const parentOperationId = normalizeOperationId(merged.parentOperationId);
|
|
133
|
+
if (workloadKind)
|
|
134
|
+
result.workloadKind = workloadKind;
|
|
135
|
+
if (operationScope)
|
|
136
|
+
result.operationScope = operationScope;
|
|
137
|
+
if (operationId)
|
|
138
|
+
result.operationId = operationId;
|
|
139
|
+
if (rootOperationId)
|
|
140
|
+
result.rootOperationId = rootOperationId;
|
|
141
|
+
if (parentOperationId)
|
|
142
|
+
result.parentOperationId = parentOperationId;
|
|
143
|
+
if (result.workloadKind && result.workloadKind !== 'agent_mediated') {
|
|
144
|
+
delete result.agentFramework;
|
|
145
|
+
delete result.agentFrameworkVersion;
|
|
146
|
+
}
|
|
147
|
+
// Do not turn an empty/invalid attribution object into attributed traffic
|
|
148
|
+
// solely because the transport happens to have a request ID.
|
|
149
|
+
if (!hasValues(result))
|
|
150
|
+
return undefined;
|
|
151
|
+
if (!result.operationId) {
|
|
152
|
+
const fallback = normalizeOperationId(fallbackOperationId);
|
|
153
|
+
if (fallback)
|
|
154
|
+
result.operationId = fallback;
|
|
155
|
+
}
|
|
156
|
+
if (result.operationId && !result.operationScope) {
|
|
157
|
+
result.operationScope =
|
|
158
|
+
result.parentOperationId ||
|
|
159
|
+
(result.rootOperationId && result.rootOperationId !== result.operationId)
|
|
160
|
+
? 'child'
|
|
161
|
+
: 'top_level';
|
|
162
|
+
}
|
|
163
|
+
if (result.operationScope === 'child' && result.rootOperationId && !result.parentOperationId) {
|
|
164
|
+
result.parentOperationId = result.rootOperationId;
|
|
165
|
+
}
|
|
166
|
+
if (result.operationScope === 'top_level' && result.operationId) {
|
|
167
|
+
result.rootOperationId = result.operationId;
|
|
168
|
+
delete result.parentOperationId;
|
|
169
|
+
}
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
/** Add flat camelCase connection attribution fields to a WebSocket URL. */
|
|
173
|
+
export function appendConnectionAttributionQuery(url, attribution) {
|
|
174
|
+
if (!attribution)
|
|
175
|
+
return;
|
|
176
|
+
const fields = [
|
|
177
|
+
'interactionKind',
|
|
178
|
+
'agentFramework',
|
|
179
|
+
'agentFrameworkVersion',
|
|
180
|
+
'agentSurface',
|
|
181
|
+
'agentSurfaceVersion',
|
|
182
|
+
'executionMode'
|
|
183
|
+
];
|
|
184
|
+
for (const field of fields) {
|
|
185
|
+
const value = attribution[field];
|
|
186
|
+
if (typeof value === 'string')
|
|
187
|
+
url.searchParams.set(field, value);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Return flat camelCase workload fields for socket request payloads. */
|
|
191
|
+
export function workloadAttributionToWireFields(attribution) {
|
|
192
|
+
if (!attribution)
|
|
193
|
+
return {};
|
|
194
|
+
const result = {};
|
|
195
|
+
for (const field of [
|
|
196
|
+
'workloadKind',
|
|
197
|
+
'agentFramework',
|
|
198
|
+
'agentFrameworkVersion',
|
|
199
|
+
'agentSurface',
|
|
200
|
+
'agentSurfaceVersion',
|
|
201
|
+
'executionMode',
|
|
202
|
+
'operationScope',
|
|
203
|
+
'operationId',
|
|
204
|
+
'rootOperationId',
|
|
205
|
+
'parentOperationId'
|
|
206
|
+
]) {
|
|
207
|
+
const value = attribution[field];
|
|
208
|
+
if (typeof value === 'string')
|
|
209
|
+
result[field] = value;
|
|
210
|
+
}
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Build headers only for requests whose caller has already established that
|
|
215
|
+
* the destination is a Sogni-owned endpoint.
|
|
216
|
+
*/
|
|
217
|
+
export function buildSogniAttributionHeaders({ appSource, connection, workload }) {
|
|
218
|
+
const headers = {};
|
|
219
|
+
const normalizedAppSource = normalizeBoundedString(appSource, MAX_METADATA_LENGTH);
|
|
220
|
+
if (normalizedAppSource)
|
|
221
|
+
headers['X-App-Source'] = normalizedAppSource;
|
|
222
|
+
if (connection === null || connection === void 0 ? void 0 : connection.interactionKind) {
|
|
223
|
+
headers['X-Sogni-Interaction-Kind'] = connection.interactionKind;
|
|
224
|
+
}
|
|
225
|
+
if (workload === null || workload === void 0 ? void 0 : workload.workloadKind) {
|
|
226
|
+
headers['X-Sogni-Workload-Kind'] = workload.workloadKind;
|
|
227
|
+
}
|
|
228
|
+
if (workload === null || workload === void 0 ? void 0 : workload.agentFramework) {
|
|
229
|
+
headers['X-Sogni-Agent-Framework'] = workload.agentFramework;
|
|
230
|
+
}
|
|
231
|
+
if (workload === null || workload === void 0 ? void 0 : workload.agentFrameworkVersion) {
|
|
232
|
+
headers['X-Sogni-Agent-Framework-Version'] = workload.agentFrameworkVersion;
|
|
233
|
+
}
|
|
234
|
+
if (workload === null || workload === void 0 ? void 0 : workload.agentSurface) {
|
|
235
|
+
headers['X-Sogni-Agent-Surface'] = workload.agentSurface;
|
|
236
|
+
}
|
|
237
|
+
if (workload === null || workload === void 0 ? void 0 : workload.agentSurfaceVersion) {
|
|
238
|
+
headers['X-Sogni-Agent-Surface-Version'] = workload.agentSurfaceVersion;
|
|
239
|
+
}
|
|
240
|
+
if (workload === null || workload === void 0 ? void 0 : workload.executionMode) {
|
|
241
|
+
headers['X-Sogni-Execution-Mode'] = workload.executionMode;
|
|
242
|
+
}
|
|
243
|
+
if (workload === null || workload === void 0 ? void 0 : workload.operationScope) {
|
|
244
|
+
headers['X-Sogni-Operation-Scope'] = workload.operationScope;
|
|
245
|
+
}
|
|
246
|
+
if (workload === null || workload === void 0 ? void 0 : workload.operationId) {
|
|
247
|
+
headers['X-Sogni-Operation-Id'] = workload.operationId;
|
|
248
|
+
}
|
|
249
|
+
if (workload === null || workload === void 0 ? void 0 : workload.rootOperationId) {
|
|
250
|
+
headers['X-Sogni-Root-Operation-Id'] = workload.rootOperationId;
|
|
251
|
+
}
|
|
252
|
+
if (workload === null || workload === void 0 ? void 0 : workload.parentOperationId) {
|
|
253
|
+
headers['X-Sogni-Parent-Operation-Id'] = workload.parentOperationId;
|
|
254
|
+
}
|
|
255
|
+
return headers;
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=attribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribution.js","sourceRoot":"","sources":["../../src/lib/attribution.ts"],"names":[],"mappings":"AAYA,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AACxD,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAClD,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAE7D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAkB;IACjD,UAAU;IACV,gBAAgB;IAChB,SAAS;IACT,SAAS;CACV,CAAC,CAAC;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAe,CAAC,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AACjG,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAiB,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AACpF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAe;IAC3C,YAAY;IACZ,eAAe;IACf,gBAAgB;IAChB,QAAQ;IACR,gBAAgB;IAChB,KAAK;IACL,KAAK;IACL,KAAK;IACL,mBAAmB;IACnB,YAAY;IACZ,SAAS;CACV,CAAC,CAAC;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAK5F,SAAS,aAAa,CAAmB,KAAc,EAAE,OAAuB;IAC9E,IAAI,OAAO,KAAK,KAA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Root":"","sources":["../../src/types/attribution.ts"],"names":[],"mappings":""}
|
package/dist-esm/version.js
CHANGED
package/llms-full.txt
CHANGED
|
@@ -254,6 +254,33 @@ const portal = await sogni.account.createSubscriptionPortalSession();
|
|
|
254
254
|
|
|
255
255
|
`checkAuth()` is only for cookie-auth browser flows on permitted Sogni domains. API-key auth auto-authenticates during `createInstance()`. Username/password auth uses `sogni.account.login()`. Token auth can be resumed with `sogni.setTokens()`.
|
|
256
256
|
|
|
257
|
+
AGENT ATTRIBUTION:
|
|
258
|
+
|
|
259
|
+
Keep `appSource` as the stable product/integration identifier. Agent wrappers may add immutable `attribution.connection` and `attribution.workload` defaults:
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
const sogni = await SogniClient.createInstance({
|
|
263
|
+
appId: 'my-agent',
|
|
264
|
+
appSource: 'my-agent-integration',
|
|
265
|
+
apiKey: process.env.SOGNI_API_KEY,
|
|
266
|
+
attribution: {
|
|
267
|
+
connection: {
|
|
268
|
+
interactionKind: 'external_agent',
|
|
269
|
+
agentFramework: 'codex',
|
|
270
|
+
agentSurface: 'plugin'
|
|
271
|
+
},
|
|
272
|
+
workload: {
|
|
273
|
+
workloadKind: 'agent_mediated',
|
|
274
|
+
agentFramework: 'codex',
|
|
275
|
+
agentSurface: 'plugin',
|
|
276
|
+
executionMode: 'server'
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Project, socket chat, hosted chat/tool, durable chat run, and creative workflow calls accept an optional per-operation `attribution` override. Standalone attributed requests default to `operationScope: 'top_level'` and use the underlying project/job request ID. For child work, pass `operationScope: 'child'`, a stable `rootOperationId`, and the immediate `parentOperationId`; omit `operationId` to use the request's generated ID. The exported attribution types include `native_desktop`. Invalid metadata is dropped, the server remains authoritative, and all new wire fields are omitted when attribution is not configured.
|
|
283
|
+
|
|
257
284
|
NETWORK TYPES:
|
|
258
285
|
|
|
259
286
|
- 'fast': High-end GPU workers. Faster, higher cost. REQUIRED for video.
|
package/llms.txt
CHANGED
|
@@ -140,6 +140,10 @@ const portal = await sogni.account.createSubscriptionPortalSession();
|
|
|
140
140
|
|
|
141
141
|
Checkout and portal sessions require user authentication; API-key auth is rejected for those redirect operations.
|
|
142
142
|
|
|
143
|
+
AGENT ATTRIBUTION:
|
|
144
|
+
|
|
145
|
+
Keep `appSource` as the stable product/integration ID. Agent wrappers may additionally set immutable `attribution.connection` and `attribution.workload` defaults on `createInstance()`, then override `attribution` per project, socket/hosted/durable chat request, hosted tool, or creative workflow. Exported unions cover `interactionKind`, `workloadKind`, `agentSurface` (including `native_desktop`), `executionMode`, and operation lineage. Standalone attributed calls receive a top-level operation ID from the underlying job/request; child calls should provide `operationScope: 'child'`, `rootOperationId`, and `parentOperationId`. All fields are optional and omitted for legacy callers.
|
|
146
|
+
|
|
143
147
|
### Network Types
|
|
144
148
|
|
|
145
149
|
- `fast` - High-end GPUs, faster, more expensive. **Required for video.**
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "5.
|
|
6
|
+
"version": "5.3.1",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=22"
|
|
9
9
|
},
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"prepublishOnly": "npm run build",
|
|
62
62
|
"build": "npm run clean && npm run codegen && tsc --project tsconfig.json && tsc --project tsconfig.esm.json && node scripts/write-dist-esm-package-json.mjs",
|
|
63
63
|
"test:chat-routing": "npm run build && node scripts/check-chat-model-routing.cjs",
|
|
64
|
+
"test:attribution": "npm run build && node scripts/check-attribution-transport.cjs",
|
|
64
65
|
"test:subscription-api": "npm run build && node scripts/check-subscription-api.cjs",
|
|
65
66
|
"test:workflow-template-envelope": "npm run build && node scripts/check-workflow-template-envelope.cjs",
|
|
66
67
|
"watch": "npm run clean && npm run codegen && tsc --watch --project tsconfig.json",
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
"homepage": "https://github.com/Sogni-AI/sogni-client#readme",
|
|
85
86
|
"dependencies": {
|
|
86
87
|
"@lukeed/uuid": "^2.0.1",
|
|
87
|
-
"@sogni-ai/sogni-protocol": "1.0.0-alpha.
|
|
88
|
+
"@sogni-ai/sogni-protocol": "1.0.0-alpha.10",
|
|
88
89
|
"@types/js-cookie": "^3.0.6",
|
|
89
90
|
"@types/lodash": "^4.17.23",
|
|
90
91
|
"@types/ws": "^8.5.13",
|
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
SocketEventSubscriptionInput,
|
|
15
15
|
SocketEventSubscriptions
|
|
16
16
|
} from '../eventSubscriptions.js';
|
|
17
|
+
import type { NormalizedConnectionAttribution } from '../../../lib/attribution.js';
|
|
17
18
|
|
|
18
19
|
interface SocketSend<T extends MessageType = MessageType> {
|
|
19
20
|
type: 'socket-send';
|
|
@@ -114,7 +115,8 @@ class BrowserWebSocketClient extends RestClient<SocketEventMap> implements IWebS
|
|
|
114
115
|
supernetType: SupernetType,
|
|
115
116
|
logger: Logger,
|
|
116
117
|
appSource?: string,
|
|
117
|
-
socketEventSubscriptions?: SocketEventSubscriptions
|
|
118
|
+
socketEventSubscriptions?: SocketEventSubscriptions,
|
|
119
|
+
connectionAttribution?: NormalizedConnectionAttribution
|
|
118
120
|
) {
|
|
119
121
|
const socketClient = new WrappedClient(
|
|
120
122
|
baseUrl,
|
|
@@ -123,7 +125,8 @@ class BrowserWebSocketClient extends RestClient<SocketEventMap> implements IWebS
|
|
|
123
125
|
supernetType,
|
|
124
126
|
logger,
|
|
125
127
|
appSource,
|
|
126
|
-
socketEventSubscriptions
|
|
128
|
+
socketEventSubscriptions,
|
|
129
|
+
connectionAttribution
|
|
127
130
|
);
|
|
128
131
|
super(socketClient.baseUrl, auth, logger);
|
|
129
132
|
this.socketClient = socketClient;
|
|
@@ -16,6 +16,11 @@ import type {
|
|
|
16
16
|
SocketEventSubscriptionInput,
|
|
17
17
|
SocketEventSubscriptions
|
|
18
18
|
} from './eventSubscriptions.js';
|
|
19
|
+
import {
|
|
20
|
+
appendConnectionAttributionQuery,
|
|
21
|
+
normalizeConnectionAttribution,
|
|
22
|
+
type NormalizedConnectionAttribution
|
|
23
|
+
} from '../../lib/attribution.js';
|
|
19
24
|
|
|
20
25
|
const PROTOCOL_VERSION = '3.0.0';
|
|
21
26
|
|
|
@@ -24,6 +29,7 @@ const PING_INTERVAL = 15000;
|
|
|
24
29
|
class WebSocketClient extends RestClient<SocketEventMap> implements IWebSocketClient {
|
|
25
30
|
appId: string;
|
|
26
31
|
appSource?: string;
|
|
32
|
+
connectionAttribution?: NormalizedConnectionAttribution;
|
|
27
33
|
baseUrl: string;
|
|
28
34
|
socketEventSubscriptions?: SocketEventSubscriptions;
|
|
29
35
|
private socket: WebSocket | null = null;
|
|
@@ -37,7 +43,8 @@ class WebSocketClient extends RestClient<SocketEventMap> implements IWebSocketCl
|
|
|
37
43
|
supernetType: SupernetType,
|
|
38
44
|
logger: Logger,
|
|
39
45
|
appSource?: string,
|
|
40
|
-
socketEventSubscriptions?: SocketEventSubscriptions
|
|
46
|
+
socketEventSubscriptions?: SocketEventSubscriptions,
|
|
47
|
+
connectionAttribution?: NormalizedConnectionAttribution
|
|
41
48
|
) {
|
|
42
49
|
const _baseUrl = new URL(baseUrl);
|
|
43
50
|
switch (_baseUrl.protocol) {
|
|
@@ -55,6 +62,7 @@ class WebSocketClient extends RestClient<SocketEventMap> implements IWebSocketCl
|
|
|
55
62
|
super(_baseUrl.toString(), auth, logger);
|
|
56
63
|
this.appId = appId;
|
|
57
64
|
this.appSource = appSource?.trim() || undefined;
|
|
65
|
+
this.connectionAttribution = normalizeConnectionAttribution(connectionAttribution);
|
|
58
66
|
this.socketEventSubscriptions = socketEventSubscriptions;
|
|
59
67
|
this.baseUrl = _baseUrl.toString();
|
|
60
68
|
this._supernetType = supernetType;
|
|
@@ -87,6 +95,7 @@ class WebSocketClient extends RestClient<SocketEventMap> implements IWebSocketCl
|
|
|
87
95
|
if (this.appSource) {
|
|
88
96
|
url.searchParams.set('appSource', this.appSource);
|
|
89
97
|
}
|
|
98
|
+
appendConnectionAttributionQuery(url, this.connectionAttribution);
|
|
90
99
|
const socketEventSubscriptions = serializeSocketEventSubscriptions(
|
|
91
100
|
this.socketEventSubscriptions
|
|
92
101
|
);
|
package/src/ApiClient/index.ts
CHANGED
|
@@ -16,6 +16,17 @@ import CookieAuthManager from '../lib/AuthManager/CookieAuthManager.js';
|
|
|
16
16
|
import { AuthManager, TokenAuthManager } from '../lib/AuthManager/index.js';
|
|
17
17
|
import isNodejs from '../lib/isNodejs.js';
|
|
18
18
|
import BrowserWebSocketClient from './WebSocketClient/BrowserWebSocketClient/index.js';
|
|
19
|
+
import {
|
|
20
|
+
buildSogniAttributionHeaders,
|
|
21
|
+
normalizeConnectionAttribution,
|
|
22
|
+
resolveWorkloadAttribution,
|
|
23
|
+
type NormalizedConnectionAttribution
|
|
24
|
+
} from '../lib/attribution.js';
|
|
25
|
+
import type {
|
|
26
|
+
SogniAttributionConfig,
|
|
27
|
+
WorkloadAttributionDefaults,
|
|
28
|
+
WorkloadAttributionInput
|
|
29
|
+
} from '../types/attribution.js';
|
|
19
30
|
|
|
20
31
|
const WS_RECONNECT_ATTEMPTS = 5;
|
|
21
32
|
|
|
@@ -46,6 +57,7 @@ export interface ApiClientOptions {
|
|
|
46
57
|
socketUrl: string;
|
|
47
58
|
appId: string;
|
|
48
59
|
appSource?: string;
|
|
60
|
+
attribution?: SogniAttributionConfig;
|
|
49
61
|
socketEventSubscriptions?: SocketEventSubscriptions;
|
|
50
62
|
networkType: SupernetType;
|
|
51
63
|
logger: Logger;
|
|
@@ -57,6 +69,10 @@ export interface ApiClientOptions {
|
|
|
57
69
|
class ApiClient extends TypedEventEmitter<ApiClientEvents> {
|
|
58
70
|
readonly appId: string;
|
|
59
71
|
readonly appSource?: string;
|
|
72
|
+
readonly attribution: Readonly<{
|
|
73
|
+
connection?: Readonly<NormalizedConnectionAttribution>;
|
|
74
|
+
workload?: Readonly<WorkloadAttributionDefaults>;
|
|
75
|
+
}>;
|
|
60
76
|
readonly logger: Logger;
|
|
61
77
|
private _rest: RestClient;
|
|
62
78
|
private _socket: IWebSocketClient;
|
|
@@ -69,6 +85,7 @@ class ApiClient extends TypedEventEmitter<ApiClientEvents> {
|
|
|
69
85
|
socketUrl,
|
|
70
86
|
appId,
|
|
71
87
|
appSource,
|
|
88
|
+
attribution,
|
|
72
89
|
socketEventSubscriptions,
|
|
73
90
|
networkType,
|
|
74
91
|
authType,
|
|
@@ -79,6 +96,11 @@ class ApiClient extends TypedEventEmitter<ApiClientEvents> {
|
|
|
79
96
|
super();
|
|
80
97
|
this.appId = appId;
|
|
81
98
|
this.appSource = appSource?.trim() || undefined;
|
|
99
|
+
const connectionAttribution = normalizeConnectionAttribution(attribution?.connection);
|
|
100
|
+
this.attribution = Object.freeze({
|
|
101
|
+
...(connectionAttribution ? { connection: Object.freeze(connectionAttribution) } : {}),
|
|
102
|
+
...(attribution?.workload ? { workload: Object.freeze({ ...attribution.workload }) } : {})
|
|
103
|
+
});
|
|
82
104
|
this.logger = logger;
|
|
83
105
|
if (authType === 'apiKey') {
|
|
84
106
|
this._auth = new ApiKeyAuthManager(logger);
|
|
@@ -98,7 +120,8 @@ class ApiClient extends TypedEventEmitter<ApiClientEvents> {
|
|
|
98
120
|
networkType,
|
|
99
121
|
logger,
|
|
100
122
|
this.appSource,
|
|
101
|
-
socketEventSubscriptions
|
|
123
|
+
socketEventSubscriptions,
|
|
124
|
+
this.attribution.connection
|
|
102
125
|
);
|
|
103
126
|
} else {
|
|
104
127
|
this._socket = new WebSocketClient(
|
|
@@ -108,7 +131,8 @@ class ApiClient extends TypedEventEmitter<ApiClientEvents> {
|
|
|
108
131
|
networkType,
|
|
109
132
|
logger,
|
|
110
133
|
this.appSource,
|
|
111
|
-
socketEventSubscriptions
|
|
134
|
+
socketEventSubscriptions,
|
|
135
|
+
this.attribution.connection
|
|
112
136
|
);
|
|
113
137
|
}
|
|
114
138
|
this._disableSocket = disableSocket;
|
|
@@ -137,6 +161,22 @@ class ApiClient extends TypedEventEmitter<ApiClientEvents> {
|
|
|
137
161
|
return !this._disableSocket;
|
|
138
162
|
}
|
|
139
163
|
|
|
164
|
+
resolveWorkloadAttribution(override?: WorkloadAttributionInput, fallbackOperationId?: string) {
|
|
165
|
+
return resolveWorkloadAttribution(this.attribution.workload, override, fallbackOperationId);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
attributionHeaders(
|
|
169
|
+
appSource: string | undefined,
|
|
170
|
+
override?: WorkloadAttributionInput,
|
|
171
|
+
fallbackOperationId?: string
|
|
172
|
+
): Record<string, string> {
|
|
173
|
+
return buildSogniAttributionHeaders({
|
|
174
|
+
appSource,
|
|
175
|
+
connection: this.attribution.connection,
|
|
176
|
+
workload: this.resolveWorkloadAttribution(override, fallbackOperationId)
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
140
180
|
setSocketEventSubscriptions(update: SocketEventSubscriptionInput): Promise<void> {
|
|
141
181
|
return this.socket.setSocketEventSubscriptions(update);
|
|
142
182
|
}
|
package/src/ApiGroup.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import ApiClient from './ApiClient/index.js';
|
|
2
2
|
import EIP712Helper from './lib/EIP712Helper.js';
|
|
3
3
|
import TypedEventEmitter, { EventMap } from './lib/TypedEventEmitter.js';
|
|
4
|
+
import { buildSogniAttributionHeaders, resolveWorkloadAttribution } from './lib/attribution.js';
|
|
5
|
+
import type { WorkloadAttributionInput } from './types/attribution.js';
|
|
4
6
|
|
|
5
7
|
export interface ApiConfig {
|
|
6
8
|
client: ApiClient;
|
|
@@ -16,6 +18,29 @@ abstract class ApiGroup<E extends EventMap = {}> extends TypedEventEmitter<E> {
|
|
|
16
18
|
this.client = config.client;
|
|
17
19
|
this.eip712 = config.eip712;
|
|
18
20
|
}
|
|
21
|
+
|
|
22
|
+
protected resolveWorkloadAttribution(
|
|
23
|
+
override?: WorkloadAttributionInput,
|
|
24
|
+
fallbackOperationId?: string
|
|
25
|
+
) {
|
|
26
|
+
return resolveWorkloadAttribution(
|
|
27
|
+
this.client.attribution?.workload,
|
|
28
|
+
override,
|
|
29
|
+
fallbackOperationId
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
protected attributionHeaders(
|
|
34
|
+
appSource: string | undefined,
|
|
35
|
+
override?: WorkloadAttributionInput,
|
|
36
|
+
fallbackOperationId?: string
|
|
37
|
+
): Record<string, string> {
|
|
38
|
+
return buildSogniAttributionHeaders({
|
|
39
|
+
appSource,
|
|
40
|
+
connection: this.client.attribution?.connection,
|
|
41
|
+
workload: this.resolveWorkloadAttribution(override, fallbackOperationId)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
19
44
|
}
|
|
20
45
|
|
|
21
46
|
export default ApiGroup;
|
package/src/Chat/ChatTools.ts
CHANGED
|
@@ -155,6 +155,7 @@ class ChatToolsApi {
|
|
|
155
155
|
tokenType: options?.tokenType,
|
|
156
156
|
network: options?.network,
|
|
157
157
|
numberOfMedia: options?.numberOfMedia,
|
|
158
|
+
attribution: options?.attribution,
|
|
158
159
|
timeout: options?.timeout,
|
|
159
160
|
onProgress: options?.onToolProgress
|
|
160
161
|
? (progress: ToolExecutionProgress) => options.onToolProgress!(toolCall, progress)
|
|
@@ -213,7 +214,10 @@ class ChatToolsApi {
|
|
|
213
214
|
): Promise<ToolExecutionResult> {
|
|
214
215
|
options?.onProgress?.({ status: 'creating', percent: 0 });
|
|
215
216
|
|
|
216
|
-
const project = await this.projects.create(
|
|
217
|
+
const project = await this.projects.create({
|
|
218
|
+
...projectParams,
|
|
219
|
+
...(options?.attribution ? { attribution: options.attribution } : {})
|
|
220
|
+
} as any);
|
|
217
221
|
const timeout = options?.timeout ?? DEFAULT_TIMEOUT;
|
|
218
222
|
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
219
223
|
let jobsCompleted = 0;
|