@sogni-ai/sogni-client 5.61.0 → 5.62.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/CHANGELOG.md +7 -0
- package/README.md +13 -0
- package/dist/Worlds/index.d.ts +43 -0
- package/dist/Worlds/index.js +308 -0
- package/dist/Worlds/index.js.map +1 -0
- package/dist/Worlds/types.d.ts +181 -0
- package/dist/Worlds/types.js +11 -0
- package/dist/Worlds/types.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist-esm/Worlds/index.js +303 -0
- package/dist-esm/Worlds/index.js.map +1 -0
- package/dist-esm/Worlds/types.js +10 -0
- package/dist-esm/Worlds/types.js.map +1 -0
- package/dist-esm/index.js +2 -0
- package/dist-esm/index.js.map +1 -1
- package/dist-esm/version.js +1 -1
- package/package.json +3 -2
- package/src/Worlds/index.ts +297 -0
- package/src/Worlds/types.ts +184 -0
- package/src/index.ts +29 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [5.62.0](https://github.com/Sogni-AI/sogni-client/compare/v5.61.0...v5.62.0) (2026-10-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **worlds:** hosted world builds on the SDK as worlds.builds ([531c039](https://github.com/Sogni-AI/sogni-client/commit/531c039134b65cad69bc56c442033b1c0ab9b29f))
|
|
7
|
+
|
|
1
8
|
# [5.61.0](https://github.com/Sogni-AI/sogni-client/compare/v5.60.8...v5.61.0) (2026-10-06)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -1578,6 +1578,19 @@ See `examples/workflow_creative_agent_workflows.mjs` for start/list/get/events/s
|
|
|
1578
1578
|
|
|
1579
1579
|
## Code Examples
|
|
1580
1580
|
|
|
1581
|
+
### Hosted World Builds (server-side)
|
|
1582
|
+
|
|
1583
|
+
A hosted world build renders the paths, moments and collectibles a person chose for one scene of their Sogni World in the background, with the account's own key, while they are away. It starts from a signed-in session (an API key cannot author a world), pauses for the quote before anything paid, and pauses again when finished takes await review; publication stays in the World studio. The SDK exposes it through `sogni.worlds.builds`:
|
|
1584
|
+
|
|
1585
|
+
- `sogni.worlds.builds.start({ worldId, nodeId, hotspots, look, tokenType, billingMode, idempotencyKey })` — start a build; each hotspot names the object as it appears, its kind (`path`, `moment` or `collectible`), the action, and for a path where it leads
|
|
1586
|
+
- `sogni.worlds.builds.get(runId)` and `.list({ worldId })` — inspect builds
|
|
1587
|
+
- `sogni.worlds.builds.events(runId, after)` and `.streamEvents(runId, { lastEventId })` — the event history and the SSE stream with `Last-Event-ID` replay
|
|
1588
|
+
- `sogni.worlds.builds.confirmCost(runId, { decision: 'confirm' | 'cancel' | 'requote' })` — answer the quote (a quote is good for ten minutes; ask for a requote after that)
|
|
1589
|
+
- `sogni.worlds.builds.review(runId, { taskId, decision: 'approved' | 'rejected', note })` — a verdict on a take in review; a rejection with a note sends it back for one rewrite
|
|
1590
|
+
- `sogni.worlds.builds.cancel(runId, reason)` — stop the build
|
|
1591
|
+
|
|
1592
|
+
Read `run.waiting.reason` to see what the build needs: `cost_approval_required`, `review_required` or `insufficient_credit`. Each task's `generationId` (a path) or `interactionId` (a moment or collectible) is the World record to publish from the studio once approved.
|
|
1593
|
+
|
|
1581
1594
|
### SAM 3 object selection
|
|
1582
1595
|
|
|
1583
1596
|
SAM 3 (`sam3_image_segment_bf16`, SDK 5.31.0+) selects objects in an existing
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import ApiGroup, { ApiConfig } from '../ApiGroup.js';
|
|
2
|
+
import type { ConfirmWorldBuildCostParams, ListWorldBuildsOptions, ReviewWorldBuildTaskParams, StartWorldBuildParams, StreamWorldBuildEventsOptions, WorldBuildEvent, WorldBuildRecord } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Sogni Worlds, as the platform hosts them (`/v1/world-builds`).
|
|
5
|
+
*
|
|
6
|
+
* A hosted world build runs server-side with the account's own key: the
|
|
7
|
+
* person starts it from a signed-in session, approves the quote, and approves
|
|
8
|
+
* or rejects every finished take. API-key sessions cannot start one.
|
|
9
|
+
*
|
|
10
|
+
* - `builds.start` returns the persisted run (202); the executor prices the
|
|
11
|
+
* work and pauses with `waiting.reason: 'cost_approval_required'`.
|
|
12
|
+
* - `builds.confirmCost` answers the quote: confirm, cancel or requote.
|
|
13
|
+
* - `builds.review` records a verdict on a take in `review`; a rejection with
|
|
14
|
+
* a note sends it back for one rewrite.
|
|
15
|
+
* - `builds.streamEvents` yields `WorldBuildEvent`s over SSE with
|
|
16
|
+
* `Last-Event-ID` replay; `builds.events` lists them.
|
|
17
|
+
*/
|
|
18
|
+
declare class WorldsApi extends ApiGroup {
|
|
19
|
+
builds: {
|
|
20
|
+
start: (params: StartWorldBuildParams) => Promise<WorldBuildRecord>;
|
|
21
|
+
list: (options?: ListWorldBuildsOptions) => Promise<WorldBuildRecord[]>;
|
|
22
|
+
get: (runId: string) => Promise<WorldBuildRecord>;
|
|
23
|
+
events: (runId: string, afterSequence?: number) => Promise<WorldBuildEvent[]>;
|
|
24
|
+
streamEvents: (runId: string, options?: StreamWorldBuildEventsOptions) => AsyncIterableIterator<WorldBuildEvent>;
|
|
25
|
+
confirmCost: (runId: string, params: ConfirmWorldBuildCostParams) => Promise<WorldBuildRecord>;
|
|
26
|
+
review: (runId: string, params: ReviewWorldBuildTaskParams) => Promise<WorldBuildRecord>;
|
|
27
|
+
cancel: (runId: string, reason?: string) => Promise<WorldBuildRecord>;
|
|
28
|
+
};
|
|
29
|
+
constructor(config: ApiConfig);
|
|
30
|
+
/** An authenticated fetch bound to the current session: a session change cancels it. */
|
|
31
|
+
private buildFetch;
|
|
32
|
+
private buildJson;
|
|
33
|
+
private startBuild;
|
|
34
|
+
private listBuilds;
|
|
35
|
+
private getBuild;
|
|
36
|
+
private listBuildEvents;
|
|
37
|
+
private confirmBuildCost;
|
|
38
|
+
private reviewBuildTask;
|
|
39
|
+
private cancelBuild;
|
|
40
|
+
/** SSE events, replayed from `lastEventId` and then live until the run ends or the signal aborts. */
|
|
41
|
+
private streamBuildEvents;
|
|
42
|
+
}
|
|
43
|
+
export default WorldsApi;
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
12
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
13
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
14
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
15
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
16
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
17
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
18
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
19
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
20
|
+
function fulfill(value) { resume("next", value); }
|
|
21
|
+
function reject(value) { resume("throw", value); }
|
|
22
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
23
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
const ApiGroup_js_1 = __importDefault(require("../ApiGroup.js"));
|
|
29
|
+
const apiErrorFields_js_1 = require("../lib/apiErrorFields.js");
|
|
30
|
+
const getUUID_js_1 = __importDefault(require("../lib/getUUID.js"));
|
|
31
|
+
const requestSession_js_1 = require("../lib/requestSession.js");
|
|
32
|
+
/**
|
|
33
|
+
* Sogni Worlds, as the platform hosts them (`/v1/world-builds`).
|
|
34
|
+
*
|
|
35
|
+
* A hosted world build runs server-side with the account's own key: the
|
|
36
|
+
* person starts it from a signed-in session, approves the quote, and approves
|
|
37
|
+
* or rejects every finished take. API-key sessions cannot start one.
|
|
38
|
+
*
|
|
39
|
+
* - `builds.start` returns the persisted run (202); the executor prices the
|
|
40
|
+
* work and pauses with `waiting.reason: 'cost_approval_required'`.
|
|
41
|
+
* - `builds.confirmCost` answers the quote: confirm, cancel or requote.
|
|
42
|
+
* - `builds.review` records a verdict on a take in `review`; a rejection with
|
|
43
|
+
* a note sends it back for one rewrite.
|
|
44
|
+
* - `builds.streamEvents` yields `WorldBuildEvent`s over SSE with
|
|
45
|
+
* `Last-Event-ID` replay; `builds.events` lists them.
|
|
46
|
+
*/
|
|
47
|
+
class WorldsApi extends ApiGroup_js_1.default {
|
|
48
|
+
constructor(config) {
|
|
49
|
+
super(config);
|
|
50
|
+
this.builds = {
|
|
51
|
+
start: this.startBuild.bind(this),
|
|
52
|
+
list: this.listBuilds.bind(this),
|
|
53
|
+
get: this.getBuild.bind(this),
|
|
54
|
+
events: this.listBuildEvents.bind(this),
|
|
55
|
+
streamEvents: this.streamBuildEvents.bind(this),
|
|
56
|
+
confirmCost: this.confirmBuildCost.bind(this),
|
|
57
|
+
review: this.reviewBuildTask.bind(this),
|
|
58
|
+
cancel: this.cancelBuild.bind(this)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** An authenticated fetch bound to the current session: a session change cancels it. */
|
|
62
|
+
buildFetch(path_1) {
|
|
63
|
+
return __awaiter(this, arguments, void 0, function* (path, options = {}) {
|
|
64
|
+
var _a, _b, _c, _d, _e, _f;
|
|
65
|
+
const assertSession = (0, requestSession_js_1.captureRequestSession)(this.client.auth);
|
|
66
|
+
const url = new URL(path, this.client.rest.baseUrl).toString();
|
|
67
|
+
const controller = new AbortController();
|
|
68
|
+
const cancelChangedSession = () => {
|
|
69
|
+
try {
|
|
70
|
+
assertSession();
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
controller.abort(error);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const cancelRequested = () => { var _a; return controller.abort((_a = options.signal) === null || _a === void 0 ? void 0 : _a.reason); };
|
|
77
|
+
const offAuth = (_a = this.client.auth) === null || _a === void 0 ? void 0 : _a.on('updated', cancelChangedSession);
|
|
78
|
+
const offSession = (_b = this.client.auth) === null || _b === void 0 ? void 0 : _b.on('sessionChanged', cancelChangedSession);
|
|
79
|
+
if ((_c = options.signal) === null || _c === void 0 ? void 0 : _c.aborted)
|
|
80
|
+
cancelRequested();
|
|
81
|
+
else
|
|
82
|
+
(_d = options.signal) === null || _d === void 0 ? void 0 : _d.addEventListener('abort', cancelRequested, { once: true });
|
|
83
|
+
try {
|
|
84
|
+
const authenticated = yield this.client.auth.authenticateRequest(options);
|
|
85
|
+
assertSession();
|
|
86
|
+
const response = yield fetch(url, Object.assign(Object.assign({}, authenticated), { signal: controller.signal }));
|
|
87
|
+
try {
|
|
88
|
+
assertSession();
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
void ((_e = response.body) === null || _e === void 0 ? void 0 : _e.cancel().catch(() => undefined));
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
return response;
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
offAuth === null || offAuth === void 0 ? void 0 : offAuth();
|
|
98
|
+
offSession === null || offSession === void 0 ? void 0 : offSession();
|
|
99
|
+
(_f = options.signal) === null || _f === void 0 ? void 0 : _f.removeEventListener('abort', cancelRequested);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
buildJson(path_1) {
|
|
104
|
+
return __awaiter(this, arguments, void 0, function* (path, options = {}) {
|
|
105
|
+
var _a;
|
|
106
|
+
const assertSession = (0, requestSession_js_1.captureRequestSession)(this.client.auth);
|
|
107
|
+
const response = yield this.buildFetch(path, options);
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
const text = yield response.text();
|
|
110
|
+
assertSession();
|
|
111
|
+
let payload;
|
|
112
|
+
try {
|
|
113
|
+
payload = text ? JSON.parse(text) : undefined;
|
|
114
|
+
}
|
|
115
|
+
catch (_b) {
|
|
116
|
+
payload = { message: text };
|
|
117
|
+
}
|
|
118
|
+
const message = (payload && typeof payload.message === 'string' && payload.message) ||
|
|
119
|
+
response.statusText ||
|
|
120
|
+
`World build request failed with status ${response.status}`;
|
|
121
|
+
// Same contract as the chat run surface: the server's message, its
|
|
122
|
+
// status, its wait in seconds and any structured context it attached.
|
|
123
|
+
const err = new Error(message);
|
|
124
|
+
err.status = response.status;
|
|
125
|
+
const extras = (0, apiErrorFields_js_1.apiErrorExtras)(payload);
|
|
126
|
+
const retryAfter = (_a = extras.retryAfter) !== null && _a !== void 0 ? _a : (0, apiErrorFields_js_1.parseRetryAfterHeader)(response.headers.get('retry-after'));
|
|
127
|
+
if (retryAfter !== undefined)
|
|
128
|
+
err.retryAfter = retryAfter;
|
|
129
|
+
if (extras.details)
|
|
130
|
+
err.details = extras.details;
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
const body = (yield response.json());
|
|
134
|
+
assertSession();
|
|
135
|
+
return body;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
startBuild(params) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
const appSource = this.client.appSource;
|
|
141
|
+
const body = Object.assign(Object.assign(Object.assign(Object.assign({ worldId: params.worldId, nodeId: params.nodeId, hotspots: params.hotspots }, (params.look ? { look: params.look } : {})), (params.audience ? { audience: params.audience } : {})), (params.tokenType ? { tokenType: params.tokenType } : {})), (params.billingMode ? { billingMode: params.billingMode } : {}));
|
|
142
|
+
const headers = Object.assign({ 'Content-Type': 'application/json' }, this.attributionHeaders(appSource, undefined, (0, getUUID_js_1.default)()));
|
|
143
|
+
if (params.idempotencyKey)
|
|
144
|
+
headers['Idempotency-Key'] = params.idempotencyKey;
|
|
145
|
+
const response = yield this.buildJson('/v1/world-builds', {
|
|
146
|
+
method: 'POST',
|
|
147
|
+
headers,
|
|
148
|
+
body: JSON.stringify(body)
|
|
149
|
+
});
|
|
150
|
+
return response.data.run;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
listBuilds() {
|
|
154
|
+
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
155
|
+
const query = new URLSearchParams();
|
|
156
|
+
if (options.worldId)
|
|
157
|
+
query.set('worldId', options.worldId);
|
|
158
|
+
if (options.limit !== undefined)
|
|
159
|
+
query.set('limit', String(options.limit));
|
|
160
|
+
const suffix = query.size ? `?${query.toString()}` : '';
|
|
161
|
+
const response = yield this.buildJson(`/v1/world-builds${suffix}`);
|
|
162
|
+
return response.data.runs;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
getBuild(runId) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
const response = yield this.buildJson(`/v1/world-builds/${encodeURIComponent(runId)}`);
|
|
168
|
+
return response.data.run;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
listBuildEvents(runId, afterSequence) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
const suffix = afterSequence !== undefined ? `?after=${encodeURIComponent(String(afterSequence))}` : '';
|
|
174
|
+
const response = yield this.buildJson(`/v1/world-builds/${encodeURIComponent(runId)}/events${suffix}`);
|
|
175
|
+
return response.data.events;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
confirmBuildCost(runId, params) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const response = yield this.buildJson(`/v1/world-builds/${encodeURIComponent(runId)}/confirm-cost`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ decision: params.decision }) });
|
|
181
|
+
return response.data.run;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
reviewBuildTask(runId, params) {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
const response = yield this.buildJson(`/v1/world-builds/${encodeURIComponent(runId)}/review`, {
|
|
187
|
+
method: 'POST',
|
|
188
|
+
headers: { 'Content-Type': 'application/json' },
|
|
189
|
+
body: JSON.stringify(Object.assign({ taskId: params.taskId, decision: params.decision }, (params.note ? { note: params.note } : {})))
|
|
190
|
+
});
|
|
191
|
+
return response.data.run;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
cancelBuild(runId, reason) {
|
|
195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
const response = yield this.buildJson(`/v1/world-builds/${encodeURIComponent(runId)}/cancel`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(reason ? { reason } : {}) });
|
|
197
|
+
return response.data.run;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/** SSE events, replayed from `lastEventId` and then live until the run ends or the signal aborts. */
|
|
201
|
+
streamBuildEvents(runId_1) {
|
|
202
|
+
return __asyncGenerator(this, arguments, function* streamBuildEvents_1(runId, options = {}) {
|
|
203
|
+
var _a, _b, _c, _d;
|
|
204
|
+
const checkSession = (0, requestSession_js_1.captureRequestSession)(this.client.auth);
|
|
205
|
+
const assertSession = () => {
|
|
206
|
+
var _a, _b;
|
|
207
|
+
checkSession();
|
|
208
|
+
if ((_a = options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
209
|
+
throw (_b = options.signal.reason) !== null && _b !== void 0 ? _b : new DOMException('The request was aborted', 'AbortError');
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
const headers = { Accept: 'text/event-stream' };
|
|
213
|
+
if (options.lastEventId !== undefined && Number.isFinite(options.lastEventId)) {
|
|
214
|
+
headers['Last-Event-ID'] = String(options.lastEventId);
|
|
215
|
+
}
|
|
216
|
+
const response = yield __await(this.buildFetch(`/v1/world-builds/${encodeURIComponent(runId)}/events/stream`, {
|
|
217
|
+
headers,
|
|
218
|
+
signal: options.signal
|
|
219
|
+
}));
|
|
220
|
+
if (!response.ok || !response.body) {
|
|
221
|
+
throw new Error(`World build event stream failed with status ${response.status}`);
|
|
222
|
+
}
|
|
223
|
+
const reader = response.body.getReader();
|
|
224
|
+
const decoder = new TextDecoder();
|
|
225
|
+
let buffer = '';
|
|
226
|
+
const cancelChangedSession = () => {
|
|
227
|
+
try {
|
|
228
|
+
assertSession();
|
|
229
|
+
}
|
|
230
|
+
catch (_a) {
|
|
231
|
+
void reader.cancel().catch(() => undefined);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const offAuth = (_a = this.client.auth) === null || _a === void 0 ? void 0 : _a.on('updated', cancelChangedSession);
|
|
235
|
+
const offSession = (_b = this.client.auth) === null || _b === void 0 ? void 0 : _b.on('sessionChanged', cancelChangedSession);
|
|
236
|
+
(_c = options.signal) === null || _c === void 0 ? void 0 : _c.addEventListener('abort', cancelChangedSession, { once: true });
|
|
237
|
+
const findFrameBoundary = (source) => {
|
|
238
|
+
const lf = source.indexOf('\n\n');
|
|
239
|
+
const crlf = source.indexOf('\r\n\r\n');
|
|
240
|
+
if (lf === -1 && crlf === -1)
|
|
241
|
+
return null;
|
|
242
|
+
if (lf === -1)
|
|
243
|
+
return { index: crlf, length: 4 };
|
|
244
|
+
if (crlf === -1 || lf < crlf)
|
|
245
|
+
return { index: lf, length: 2 };
|
|
246
|
+
return { index: crlf, length: 4 };
|
|
247
|
+
};
|
|
248
|
+
const parseFrame = (frame) => {
|
|
249
|
+
if (!frame.trim() || frame.startsWith(':'))
|
|
250
|
+
return null;
|
|
251
|
+
let eventName = 'message';
|
|
252
|
+
let data = '';
|
|
253
|
+
for (const rawLine of frame.split(/\r?\n/)) {
|
|
254
|
+
if (rawLine.startsWith('event:'))
|
|
255
|
+
eventName = rawLine.slice(6).trim();
|
|
256
|
+
else if (rawLine.startsWith('data:'))
|
|
257
|
+
data += (data ? '\n' : '') + rawLine.slice(5).trim();
|
|
258
|
+
}
|
|
259
|
+
// run_status frames carry the run's status snapshot, not an event; `get` reads the same.
|
|
260
|
+
if (eventName === 'run_status' || !data)
|
|
261
|
+
return null;
|
|
262
|
+
try {
|
|
263
|
+
return JSON.parse(data);
|
|
264
|
+
}
|
|
265
|
+
catch (_a) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
try {
|
|
270
|
+
assertSession();
|
|
271
|
+
while (true) {
|
|
272
|
+
const { value, done } = yield __await(reader.read());
|
|
273
|
+
assertSession();
|
|
274
|
+
if (done) {
|
|
275
|
+
const remaining = buffer.trim();
|
|
276
|
+
if (remaining) {
|
|
277
|
+
const parsed = parseFrame(remaining);
|
|
278
|
+
if (parsed)
|
|
279
|
+
yield yield __await(parsed);
|
|
280
|
+
}
|
|
281
|
+
return yield __await(void 0);
|
|
282
|
+
}
|
|
283
|
+
buffer += decoder.decode(value, { stream: true });
|
|
284
|
+
let boundary = findFrameBoundary(buffer);
|
|
285
|
+
while (boundary !== null) {
|
|
286
|
+
const frame = buffer.slice(0, boundary.index);
|
|
287
|
+
buffer = buffer.slice(boundary.index + boundary.length);
|
|
288
|
+
boundary = findFrameBoundary(buffer);
|
|
289
|
+
const parsed = parseFrame(frame);
|
|
290
|
+
if (parsed) {
|
|
291
|
+
assertSession();
|
|
292
|
+
yield yield __await(parsed);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
finally {
|
|
298
|
+
offAuth === null || offAuth === void 0 ? void 0 : offAuth();
|
|
299
|
+
offSession === null || offSession === void 0 ? void 0 : offSession();
|
|
300
|
+
(_d = options.signal) === null || _d === void 0 ? void 0 : _d.removeEventListener('abort', cancelChangedSession);
|
|
301
|
+
yield __await(reader.cancel().catch(() => undefined));
|
|
302
|
+
reader.releaseLock();
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
exports.default = WorldsApi;
|
|
308
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Worlds/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAqD;AACrD,gEAAiF;AACjF,mEAAwC;AACxC,gEAAiE;AAgBjE;;;;;;;;;;;;;;GAcG;AACH,MAAM,SAAU,SAAQ,qBAAQ;IAY9B,YAAY,MAAiB;QAC3B,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG;YACZ,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YACjC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YAChC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAC7B,MAAM,EAAE,IAAI,CAAC,eAAe,CA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;wBAC3B,CAAC;wBACD,6BAAO;oBACT,CAAC;oBACD,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;oBAClD,IAAI,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBACzC,OAAO,QAAQ,KAAK,IAAI,EAAE,CAAC;wBACzB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;wBAC9C,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;wBACxD,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;wBACrC,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;wBACjC,IAAI,MAAM,EAAE,CAAC;4BACX,aAAa,EAAE,CAAC;4BAChB,oBAAM,MAAM,CAAA,CAAC;wBACf,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,OAAO,aAAP,OAAO,uBAAP,OAAO,EAAI,CAAC;gBACZ,UAAU,aAAV,UAAU,uBAAV,UAAU,EAAI,CAAC;gBACf,MAAA,OAAO,CAAC,MAAM,0CAAE,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;gBACnE,cAAM,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA,CAAC;gBAC7C,MAAM,CAAC,WAAW,EAAE,CAAC;YACvB,CAAC;QACH,CAAC;KAAA;CACF;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosted world builds (`/v1/world-builds`): sogni-api builds the paths,
|
|
3
|
+
* moments and collectibles a person chose for one scene of their Sogni
|
|
4
|
+
* World, in the background, with the account's own key. The person starts
|
|
5
|
+
* it from a signed-in session, approves the quote before anything paid, and
|
|
6
|
+
* approves or rejects every finished take; publication stays theirs in the
|
|
7
|
+
* World studio. Shapes mirror sogni-api `src/interface/world-build.interface.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export type WorldBuildStatus = 'queued' | 'running' | 'waiting_for_user' | 'completed' | 'partial_failure' | 'failed' | 'cancelled';
|
|
10
|
+
export type WorldBuildWaitingReason = 'cost_approval_required' | 'review_required' | 'insufficient_credit' | 'safety_review_required';
|
|
11
|
+
export interface WorldBuildWaiting {
|
|
12
|
+
reason: WorldBuildWaitingReason;
|
|
13
|
+
message: string;
|
|
14
|
+
details?: Record<string, unknown>;
|
|
15
|
+
since: string;
|
|
16
|
+
}
|
|
17
|
+
export type WorldBuildHotspotKind = 'path' | 'moment' | 'collectible';
|
|
18
|
+
export interface WorldBuildAction {
|
|
19
|
+
verb: string;
|
|
20
|
+
subject: string;
|
|
21
|
+
intent: string;
|
|
22
|
+
tone?: string;
|
|
23
|
+
}
|
|
24
|
+
/** One thing to build from the scene. `taskId` is optional; the server names unnamed ones `task_<n>`. */
|
|
25
|
+
export interface WorldBuildHotspotInput {
|
|
26
|
+
taskId?: string;
|
|
27
|
+
kind: WorldBuildHotspotKind;
|
|
28
|
+
/** The object as it appears in the picture, lower case with its article: "the brass lantern". */
|
|
29
|
+
object: string;
|
|
30
|
+
action: WorldBuildAction;
|
|
31
|
+
/** A path's destination title. */
|
|
32
|
+
leadsTo?: string;
|
|
33
|
+
/** Film length in seconds; one of the world's creator-plan lengths. */
|
|
34
|
+
duration?: number;
|
|
35
|
+
/** Where the person or the finder saw it, as fractions of the picture: a hint for the pointer. */
|
|
36
|
+
point?: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface StartWorldBuildParams {
|
|
42
|
+
worldId: string;
|
|
43
|
+
nodeId: string;
|
|
44
|
+
hotspots: WorldBuildHotspotInput[];
|
|
45
|
+
/** The world's visual style, carried into every film direction. */
|
|
46
|
+
look?: string;
|
|
47
|
+
audience?: 'everyone' | 'teen';
|
|
48
|
+
tokenType?: 'spark' | 'sogni';
|
|
49
|
+
billingMode?: 'auto' | 'subscription' | 'tokens';
|
|
50
|
+
/** Replays with the same key return the same run instead of starting another. */
|
|
51
|
+
idempotencyKey?: string;
|
|
52
|
+
}
|
|
53
|
+
export type WorldBuildTaskStep = 'pending' | 'locating' | 'outlining' | 'reserving' | 'rendering_still' | 'directing' | 'rendering_transition' | 'rendering_moment' | 'rendering_collectible' | 'review' | 'approved' | 'rejected' | 'failed' | 'cancelled';
|
|
54
|
+
export interface WorldBuildTaskSelection {
|
|
55
|
+
id: string;
|
|
56
|
+
selectionHash: string;
|
|
57
|
+
projectId: string;
|
|
58
|
+
points: Array<{
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
label: 'positive' | 'negative';
|
|
62
|
+
}>;
|
|
63
|
+
bounds: {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
};
|
|
69
|
+
coverage: number;
|
|
70
|
+
}
|
|
71
|
+
export interface WorldBuildTask {
|
|
72
|
+
taskId: string;
|
|
73
|
+
kind: WorldBuildHotspotKind;
|
|
74
|
+
status: WorldBuildTaskStep;
|
|
75
|
+
attempts: number;
|
|
76
|
+
selection?: WorldBuildTaskSelection;
|
|
77
|
+
/** The World generation behind a path; publish it through the World studio once approved. */
|
|
78
|
+
generationId?: string;
|
|
79
|
+
/** The World interaction behind a moment or collectible. */
|
|
80
|
+
interactionId?: string;
|
|
81
|
+
projects: {
|
|
82
|
+
segmentation?: string;
|
|
83
|
+
target_still?: string;
|
|
84
|
+
transition?: string;
|
|
85
|
+
interaction?: string;
|
|
86
|
+
};
|
|
87
|
+
direction?: string;
|
|
88
|
+
review?: {
|
|
89
|
+
decision: 'approved' | 'rejected';
|
|
90
|
+
note?: string;
|
|
91
|
+
at: string;
|
|
92
|
+
};
|
|
93
|
+
error?: {
|
|
94
|
+
message: string;
|
|
95
|
+
code?: string;
|
|
96
|
+
at: string;
|
|
97
|
+
step: WorldBuildTaskStep;
|
|
98
|
+
};
|
|
99
|
+
startedAt?: string;
|
|
100
|
+
finishedAt?: string;
|
|
101
|
+
}
|
|
102
|
+
export interface WorldBuildCostLine {
|
|
103
|
+
taskId: string;
|
|
104
|
+
kind: WorldBuildHotspotKind;
|
|
105
|
+
stages: Record<string, number>;
|
|
106
|
+
total: number;
|
|
107
|
+
}
|
|
108
|
+
export interface WorldBuildCostPreview {
|
|
109
|
+
tokenType: 'spark' | 'sogni';
|
|
110
|
+
billingMode: 'auto' | 'subscription' | 'tokens';
|
|
111
|
+
lines: WorldBuildCostLine[];
|
|
112
|
+
total: number;
|
|
113
|
+
coveredBySubscription: boolean;
|
|
114
|
+
issuedAt: string;
|
|
115
|
+
/** Confirm before this, or ask for a requote. */
|
|
116
|
+
validUntil: string;
|
|
117
|
+
}
|
|
118
|
+
export interface WorldBuildEvent {
|
|
119
|
+
sequence: number;
|
|
120
|
+
type: string;
|
|
121
|
+
at: string;
|
|
122
|
+
payload?: Record<string, unknown>;
|
|
123
|
+
}
|
|
124
|
+
export interface WorldBuildRecord {
|
|
125
|
+
runId: string;
|
|
126
|
+
ownerWalletAddress: string;
|
|
127
|
+
worldId: string;
|
|
128
|
+
nodeId: string;
|
|
129
|
+
status: WorldBuildStatus;
|
|
130
|
+
scope: {
|
|
131
|
+
ownerWalletAddress: string;
|
|
132
|
+
appSource: string;
|
|
133
|
+
tokenType?: 'spark' | 'sogni';
|
|
134
|
+
billingMode?: 'auto' | 'subscription' | 'tokens';
|
|
135
|
+
};
|
|
136
|
+
input: {
|
|
137
|
+
worldId: string;
|
|
138
|
+
nodeId: string;
|
|
139
|
+
look?: string;
|
|
140
|
+
audience?: 'everyone' | 'teen';
|
|
141
|
+
hotspots: Array<Required<Pick<WorldBuildHotspotInput, 'taskId'>> & WorldBuildHotspotInput>;
|
|
142
|
+
plan: Record<string, unknown>;
|
|
143
|
+
};
|
|
144
|
+
tasks: WorldBuildTask[];
|
|
145
|
+
costPreview?: WorldBuildCostPreview;
|
|
146
|
+
authorization?: {
|
|
147
|
+
acceptedTotal: number;
|
|
148
|
+
tokenType: 'spark' | 'sogni';
|
|
149
|
+
previewIssuedAt: string;
|
|
150
|
+
acceptedAt: string;
|
|
151
|
+
};
|
|
152
|
+
waiting?: WorldBuildWaiting;
|
|
153
|
+
/** Absent from list responses: a build's events are a stream, read with `events` or `streamEvents`. */
|
|
154
|
+
events?: WorldBuildEvent[];
|
|
155
|
+
failureReason?: string;
|
|
156
|
+
cancellationReason?: string;
|
|
157
|
+
timestamps: {
|
|
158
|
+
createdAt: string;
|
|
159
|
+
updatedAt: string;
|
|
160
|
+
completedAt?: string;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export interface ConfirmWorldBuildCostParams {
|
|
164
|
+
/** `confirm` starts the paid work, `cancel` ends the run, `requote` asks for a fresh price. */
|
|
165
|
+
decision: 'confirm' | 'cancel' | 'requote';
|
|
166
|
+
}
|
|
167
|
+
export interface ReviewWorldBuildTaskParams {
|
|
168
|
+
taskId: string;
|
|
169
|
+
decision: 'approved' | 'rejected';
|
|
170
|
+
/** What is wrong with a rejected take; the rewrite reads it. */
|
|
171
|
+
note?: string;
|
|
172
|
+
}
|
|
173
|
+
export interface ListWorldBuildsOptions {
|
|
174
|
+
worldId?: string;
|
|
175
|
+
limit?: number;
|
|
176
|
+
}
|
|
177
|
+
export interface StreamWorldBuildEventsOptions {
|
|
178
|
+
/** Last event sequence observed by the caller; replay starts after it. */
|
|
179
|
+
lastEventId?: number;
|
|
180
|
+
signal?: AbortSignal;
|
|
181
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hosted world builds (`/v1/world-builds`): sogni-api builds the paths,
|
|
4
|
+
* moments and collectibles a person chose for one scene of their Sogni
|
|
5
|
+
* World, in the background, with the account's own key. The person starts
|
|
6
|
+
* it from a signed-in session, approves the quote before anything paid, and
|
|
7
|
+
* approves or rejects every finished take; publication stays theirs in the
|
|
8
|
+
* World studio. Shapes mirror sogni-api `src/interface/world-build.interface.ts`.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Worlds/types.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ import { CreativeWorkflowArtifact, CreativeWorkflowEvent, CreativeWorkflowRecord
|
|
|
36
36
|
import { ForkWorkflowTemplateBody, ListWorkflowTemplatesOptions, ListWorkflowTemplatesResult, WorkflowTemplate, WorkflowTemplateAuthor, WorkflowTemplateRequestOptions, WorkflowTemplateStability, WorkflowTemplateVisibility, WorkflowTemplateVisibilityFilter } from './CreativeWorkflows/Templates/types.js';
|
|
37
37
|
import StatsApi from './Stats/index.js';
|
|
38
38
|
import ReplayApi from './Replay/index.js';
|
|
39
|
+
import WorldsApi from './Worlds/index.js';
|
|
39
40
|
import AnnouncementsApi from './Announcements/index.js';
|
|
40
41
|
import { GetReplayRecordResult, ListReplayRecordsOptions, ListReplayRecordsResult, ReplayRecordSummary, ReplayRequestOptions, ReplayWriteResult, RunRecord } from './Replay/types.js';
|
|
41
42
|
import ErrorData, { MODEL_CONSENT_REQUIRED_ERROR_CODE, MODEL_NOT_YET_AVAILABLE_ERROR_CODE, SUBSCRIPTION_ERROR_CODES } from './types/ErrorData.js';
|
|
@@ -171,6 +172,13 @@ export declare class SogniClient {
|
|
|
171
172
|
* the client connected.
|
|
172
173
|
*/
|
|
173
174
|
workflows: CreativeWorkflowsApi;
|
|
175
|
+
/**
|
|
176
|
+
* Sogni Worlds (`/v1/world-builds`). `worlds.builds` starts a hosted world
|
|
177
|
+
* build from a signed-in session, answers its quote, reviews its takes and
|
|
178
|
+
* follows it over SSE; sogni-api renders in the background with the
|
|
179
|
+
* account's own key.
|
|
180
|
+
*/
|
|
181
|
+
worlds: WorldsApi;
|
|
174
182
|
/**
|
|
175
183
|
* Replay records (`/v1/replay/records`). Writes one RunRecord per
|
|
176
184
|
* chat / harness turn and exposes list + get for the replay viewer.
|
|
@@ -219,3 +227,4 @@ export declare class SogniClient {
|
|
|
219
227
|
*/
|
|
220
228
|
static createInstance(config: SogniClientConfig | RestOnlySogniClientConfig): Promise<SogniClient>;
|
|
221
229
|
}
|
|
230
|
+
export type { ConfirmWorldBuildCostParams, ListWorldBuildsOptions, ReviewWorldBuildTaskParams, StartWorldBuildParams, StreamWorldBuildEventsOptions, WorldBuildAction, WorldBuildCostLine, WorldBuildCostPreview, WorldBuildEvent, WorldBuildHotspotInput, WorldBuildHotspotKind, WorldBuildRecord, WorldBuildStatus, WorldBuildTask, WorldBuildTaskSelection, WorldBuildTaskStep, WorldBuildWaiting, WorldBuildWaitingReason } from './Worlds/types.js';
|