@stackfactor/client-api 1.3.6 → 1.5.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/cjs/lib/avatar.d.ts +4 -6
- package/dist/cjs/lib/avatar.d.ts.map +1 -1
- package/dist/cjs/lib/avatar.js +5 -8
- package/dist/cjs/lib/avatar.js.map +1 -1
- package/dist/cjs/lib/integration.d.ts +151 -36
- package/dist/cjs/lib/integration.d.ts.map +1 -1
- package/dist/cjs/lib/integration.js +155 -41
- package/dist/cjs/lib/integration.js.map +1 -1
- package/dist/esm/lib/avatar.d.ts +4 -6
- package/dist/esm/lib/avatar.d.ts.map +1 -1
- package/dist/esm/lib/avatar.js +5 -8
- package/dist/esm/lib/avatar.js.map +1 -1
- package/dist/esm/lib/integration.d.ts +151 -36
- package/dist/esm/lib/integration.d.ts.map +1 -1
- package/dist/esm/lib/integration.js +145 -39
- package/dist/esm/lib/integration.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/lib/avatar.d.ts
CHANGED
|
@@ -24,15 +24,13 @@ export interface StoredAvatar {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* A generated avatar, from the run that generated it. The caller says nothing
|
|
27
|
-
* about WHICH avatar:
|
|
27
|
+
* about WHICH avatar: its AGENT token names the run, and the run's own record
|
|
28
28
|
* says which element, type and store. Called by the image agent's event
|
|
29
|
-
* handler with the token the execution was started with
|
|
30
|
-
* its envelope (`request.runTicket`).
|
|
29
|
+
* handler with the token the execution was started with.
|
|
31
30
|
* @param {AvatarFile[]} files The PNG for each stored size
|
|
32
31
|
* @param {Object|null} usage The generator's usage descriptor (`{ cost, tokens }`), so the credits are charged to the element; null when none
|
|
33
|
-
* @param {String} token The
|
|
34
|
-
* @param {String} runTicket The ticket from this run's envelope
|
|
32
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
35
33
|
* @returns {Promise<StoredAvatar>}
|
|
36
34
|
*/
|
|
37
|
-
export declare const storeAvatar: (files: AvatarFile[], usage: Record<string, unknown> | null, token: string
|
|
35
|
+
export declare const storeAvatar: (files: AvatarFile[], usage: Record<string, unknown> | null, token: string) => Promise<StoredAvatar>;
|
|
38
36
|
//# sourceMappingURL=avatar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../../src/lib/avatar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../../src/lib/avatar.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,GACpB,WAAW,MAAM,EACjB,MAAM,MAAM,EACZ,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,OAAO,MAAM,EACb,QAAO,MAAW,KACjB,OAAO,CAAC,IAAI,CAmBd,CAAC;AAEF,8DAA8D;AAC9D,MAAM,WAAW,UAAU;IACzB,gGAAgG;IAChG,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,8BAA8B;AAC9B,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,UAAU,EAAE,EACnB,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACrC,OAAO,MAAM,KACZ,OAAO,CAAC,YAAY,CAiBtB,CAAC"}
|
package/dist/cjs/lib/avatar.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.storeAvatar = exports.getAvatar = void 0;
|
|
4
4
|
const axiosClient_js_1 = require("./axiosClient.js");
|
|
5
|
-
const integration_js_1 = require("./integration.js");
|
|
6
5
|
/**
|
|
7
6
|
* Get avatar for an elementId
|
|
8
7
|
* @param {String} elementId
|
|
@@ -33,20 +32,18 @@ const getAvatar = (elementId, type, width, height, token, title = "") => {
|
|
|
33
32
|
exports.getAvatar = getAvatar;
|
|
34
33
|
/**
|
|
35
34
|
* A generated avatar, from the run that generated it. The caller says nothing
|
|
36
|
-
* about WHICH avatar:
|
|
35
|
+
* about WHICH avatar: its AGENT token names the run, and the run's own record
|
|
37
36
|
* says which element, type and store. Called by the image agent's event
|
|
38
|
-
* handler with the token the execution was started with
|
|
39
|
-
* its envelope (`request.runTicket`).
|
|
37
|
+
* handler with the token the execution was started with.
|
|
40
38
|
* @param {AvatarFile[]} files The PNG for each stored size
|
|
41
39
|
* @param {Object|null} usage The generator's usage descriptor (`{ cost, tokens }`), so the credits are charged to the element; null when none
|
|
42
|
-
* @param {String} token The
|
|
43
|
-
* @param {String} runTicket The ticket from this run's envelope
|
|
40
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
44
41
|
* @returns {Promise<StoredAvatar>}
|
|
45
42
|
*/
|
|
46
|
-
const storeAvatar = (files, usage, token
|
|
43
|
+
const storeAvatar = (files, usage, token) => {
|
|
47
44
|
return new Promise((resolve, reject) => {
|
|
48
45
|
const request = axiosClient_js_1.client.post("/api/v1/avatar/store", { files, usage }, {
|
|
49
|
-
headers: { authorization: token
|
|
46
|
+
headers: { authorization: token },
|
|
50
47
|
});
|
|
51
48
|
request
|
|
52
49
|
.then((response) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../../src/lib/avatar.ts"],"names":[],"mappings":";;;AACA,qDAA0C;
|
|
1
|
+
{"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../../src/lib/avatar.ts"],"names":[],"mappings":";;;AACA,qDAA0C;AAE1C;;;;;;;;;GASG;AACI,MAAM,SAAS,GAAG,CACvB,SAAiB,EACjB,IAAY,EACZ,KAAa,EACb,MAAc,EACd,KAAa,EACb,QAAgB,EAA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,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AArBW,QAAA,WAAW,eAqBtB"}
|
|
@@ -99,7 +99,7 @@ export declare const setDefaultIntegration: (id: string, token: string, capabili
|
|
|
99
99
|
* resolved configuration, the identity to act as). Called by the agent runtime
|
|
100
100
|
* in run-once mode with the token the execution was started with.
|
|
101
101
|
* @param {String} batchJobId The event record the execution was started for
|
|
102
|
-
* @param {String} token The
|
|
102
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
103
103
|
*/
|
|
104
104
|
export declare const getExecutionEnvelope: (batchJobId: string, token: string) => Promise<object>;
|
|
105
105
|
/** One permission an integration may ask an organization for. */
|
|
@@ -119,8 +119,6 @@ export interface DeclarablePermission {
|
|
|
119
119
|
* @param {String} token Authorization token (Admin - Manage Interoperability)
|
|
120
120
|
*/
|
|
121
121
|
export declare const getDeclarablePermissions: (token: string) => Promise<DeclarablePermission[]>;
|
|
122
|
-
/** The request header an agent returns its run ticket in. */
|
|
123
|
-
export declare const RUN_TICKET_HEADER = "x-stackfactor-run-ticket";
|
|
124
122
|
/** How an execution settles its run. */
|
|
125
123
|
export declare const EXECUTION_OUTCOME: {
|
|
126
124
|
readonly COMPLETED: 2;
|
|
@@ -144,53 +142,170 @@ export interface SettledExecution {
|
|
|
144
142
|
* An execution claiming its run, once: PENDING → RUNNING. Of however many
|
|
145
143
|
* executions the transport may start for one run, exactly one claim answers
|
|
146
144
|
* `claimed: true`; the others get `claimed: false` and should exit without
|
|
147
|
-
* doing the work. Which run is never sent: the run
|
|
148
|
-
* the agent runtime at start, with the token the execution was started with
|
|
149
|
-
*
|
|
150
|
-
* @param {String} token The execution's token
|
|
151
|
-
* @param {String} runTicket The ticket from this run's envelope
|
|
145
|
+
* doing the work. Which run is never sent: the run's token names it. Called by
|
|
146
|
+
* the agent runtime at start, with the token the execution was started with.
|
|
147
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
152
148
|
*/
|
|
153
|
-
export declare const claimExecution: (token: string
|
|
149
|
+
export declare const claimExecution: (token: string) => Promise<ClaimedExecution>;
|
|
154
150
|
/**
|
|
155
151
|
* An execution keeping its run alive. Called on a fast cadence (~30 s) while
|
|
156
152
|
* the handler runs, so a run that stops beating is known to be abandoned.
|
|
157
|
-
* @param {String} token The
|
|
158
|
-
* @param {String} runTicket The ticket from this run's envelope
|
|
153
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
159
154
|
*/
|
|
160
|
-
export declare const heartbeatExecution: (token: string
|
|
155
|
+
export declare const heartbeatExecution: (token: string) => Promise<void>;
|
|
161
156
|
/**
|
|
162
157
|
* An execution settling its run as COMPLETED or FAILED, with what it wants
|
|
163
158
|
* remembered. `settled: false` means the run was no longer running (the
|
|
164
159
|
* platform's sweeper got there first) and the outcome was not recorded.
|
|
165
160
|
* @param {Number} status EXECUTION_OUTCOME.COMPLETED or FAILED
|
|
166
161
|
* @param {*} outcome A result summary, or the error — kept on the run's record
|
|
167
|
-
* @param {String} token The
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
162
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
163
|
+
*/
|
|
164
|
+
export declare const settleExecution: (status: number, outcome: unknown, token: string) => Promise<SettledExecution>;
|
|
165
|
+
/** Notification statuses a run may move its own notification to. */
|
|
166
|
+
export declare const RUN_NOTIFICATION_STATUS: {
|
|
167
|
+
readonly INPROGRESS: 5;
|
|
168
|
+
readonly COMPLETED: 6;
|
|
169
|
+
readonly FAILED: 7;
|
|
170
|
+
};
|
|
171
|
+
/** What a run may save its learning content as. */
|
|
172
|
+
export declare const RUN_LEARNING_CONTENT_TYPE: {
|
|
173
|
+
readonly VIDEO: 2;
|
|
174
|
+
readonly TEXT_CONTENT: 3;
|
|
175
|
+
};
|
|
176
|
+
/** A log line a run reports; `type` defaults to "info". */
|
|
177
|
+
export interface RunLogLine {
|
|
178
|
+
type?: "info" | "warning" | "error";
|
|
179
|
+
value: string;
|
|
180
|
+
}
|
|
181
|
+
/** A run's progress as the platform stored it. */
|
|
182
|
+
export interface RunProgress {
|
|
183
|
+
percent: number;
|
|
184
|
+
message: string | null;
|
|
185
|
+
updatedAt: string;
|
|
186
|
+
}
|
|
187
|
+
/** The run's notification after an update; `cancelled` means stop working. */
|
|
188
|
+
export interface RunNotificationState {
|
|
189
|
+
status: number;
|
|
190
|
+
cancelled: boolean;
|
|
191
|
+
}
|
|
192
|
+
/** The answer to a quota consume. `unlimited`: the plan does not meter the type. */
|
|
193
|
+
export interface RunQuotaConsumed {
|
|
194
|
+
unlimited: boolean;
|
|
195
|
+
remaining: number | null;
|
|
196
|
+
}
|
|
197
|
+
/** The answer to a quota refund: the run's total refunded for the type. */
|
|
198
|
+
export interface RunQuotaRefunded {
|
|
199
|
+
refunded: number;
|
|
200
|
+
remaining: number | null;
|
|
179
201
|
}
|
|
202
|
+
/** The learning content a run saved; `created` is false when it was there already. */
|
|
203
|
+
export interface RunLearningContentSaved {
|
|
204
|
+
learningContentId: string;
|
|
205
|
+
created: boolean;
|
|
206
|
+
}
|
|
207
|
+
/** A learning activity of one of the run's micro-skills. */
|
|
208
|
+
export interface RunActivityTarget {
|
|
209
|
+
microSkillId: string;
|
|
210
|
+
learningActivityId: string;
|
|
211
|
+
}
|
|
212
|
+
/** A scene's narration; `usage` is what synthesising it consumed, when known. */
|
|
213
|
+
export interface RunSceneAudioStored {
|
|
214
|
+
stored: boolean;
|
|
215
|
+
usage: unknown;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Reports how far the run got, with log lines; kept on the run's record (the
|
|
219
|
+
* newest 200 lines).
|
|
220
|
+
* @param {Number} percent 0–100
|
|
221
|
+
* @param {String|null} message A one-line summary, e.g. "micro-skill 4 of 10"
|
|
222
|
+
* @param {RunLogLine[]} log Up to 50 lines
|
|
223
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
224
|
+
*/
|
|
225
|
+
export declare const reportRunProgress: (percent: number, message: string | null, log: RunLogLine[], token: string) => Promise<RunProgress>;
|
|
226
|
+
/**
|
|
227
|
+
* Moves the run's own notification to in progress, completed or failed, with
|
|
228
|
+
* the details the person sees. Resolves `cancelled: true` when the person
|
|
229
|
+
* cancelled it — the notification is left as they left it and the run should
|
|
230
|
+
* stop, clean up and settle.
|
|
231
|
+
* @param {Number} status A RUN_NOTIFICATION_STATUS value
|
|
232
|
+
* @param {*} details What the notification shows: progress, log, …
|
|
233
|
+
* @param {String|null} description Replaces the notification's text; null keeps it
|
|
234
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
235
|
+
*/
|
|
236
|
+
export declare const updateRunNotification: (status: number, details: unknown, description: string | null, token: string) => Promise<RunNotificationState>;
|
|
180
237
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
238
|
+
* Consumes generation quota (a GENERATE_* type) for the person the run acts
|
|
239
|
+
* for. Rejects with 400 QUOTA_EXCEEDED when fewer than `amount` remain.
|
|
240
|
+
* @param {String} type e.g. "GENERATE_LEARNING_CONTENT"
|
|
241
|
+
* @param {Number} amount 1–100
|
|
242
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
243
|
+
*/
|
|
244
|
+
export declare const consumeRunQuota: (type: string, amount: number, token: string) => Promise<RunQuotaConsumed>;
|
|
245
|
+
/**
|
|
246
|
+
* Refunds quota this same run consumed and has not refunded yet — never more;
|
|
247
|
+
* a larger refund rejects with 422.
|
|
248
|
+
* @param {String} type The type the run consumed
|
|
249
|
+
* @param {Number} amount 1–100
|
|
250
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
251
|
+
*/
|
|
252
|
+
export declare const refundRunQuota: (type: string, amount: number, token: string) => Promise<RunQuotaRefunded>;
|
|
253
|
+
/**
|
|
254
|
+
* Saves a micro-skill of the learning content the run was started for — a new
|
|
255
|
+
* one, or a new draft of one it has. The parent does not need to exist yet.
|
|
256
|
+
* @param {Object} microSkill `microSkillId` plus learning activities, objectives, …
|
|
257
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
258
|
+
*/
|
|
259
|
+
export declare const saveRunMicroSkill: (microSkill: {
|
|
260
|
+
microSkillId: string;
|
|
261
|
+
[key: string]: unknown;
|
|
262
|
+
}, token: string) => Promise<object>;
|
|
263
|
+
/**
|
|
264
|
+
* Deletes a micro-skill of the run's learning content by its record id, or all
|
|
265
|
+
* of them when `id` is null — what a cancelled or failed run cleans up.
|
|
266
|
+
* @param {String|null} id The micro-skill record's id, or null for all
|
|
267
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
268
|
+
*/
|
|
269
|
+
export declare const deleteRunMicroSkills: (id: string | null, token: string) => Promise<{
|
|
270
|
+
deleted: number;
|
|
193
271
|
}>;
|
|
272
|
+
/**
|
|
273
|
+
* Saves the learning content the run was started for, as video or text
|
|
274
|
+
* content, with the settings it was generated with. It is recorded as the work
|
|
275
|
+
* of the person the run acts for. Save it once its micro-skills are stored.
|
|
276
|
+
* @param {Number} type A RUN_LEARNING_CONTENT_TYPE value
|
|
277
|
+
* @param {Object|null} settings The generation settings; null keeps the defaults
|
|
278
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
279
|
+
*/
|
|
280
|
+
export declare const saveRunLearningContent: (type: number, settings: object | null, token: string) => Promise<RunLearningContentSaved>;
|
|
281
|
+
/**
|
|
282
|
+
* Stores an image or a video clip of one of the run's learning activities
|
|
283
|
+
* (PNG, JPEG or MP4, up to 100 MB). Any other type rejects with 400.
|
|
284
|
+
* @param {Object} target The activity, and the `mediaId` the file is stored as
|
|
285
|
+
* @param {Blob|Uint8Array} media The file's bytes (a Buffer is a Uint8Array)
|
|
286
|
+
* @param {String} mimeType "image/png", "image/jpeg" or "video/mp4"
|
|
287
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
288
|
+
*/
|
|
289
|
+
export declare const storeRunMedia: (target: RunActivityTarget & {
|
|
290
|
+
mediaId: string;
|
|
291
|
+
}, media: Blob | Uint8Array, mimeType: string, token: string) => Promise<{
|
|
292
|
+
mediaId: string;
|
|
293
|
+
}>;
|
|
294
|
+
/**
|
|
295
|
+
* Has the platform synthesise the narration of one scene of one of the run's
|
|
296
|
+
* video activities and store it where the player reads it. Resolves
|
|
297
|
+
* `stored: false` when there was nothing to store.
|
|
298
|
+
* @param {Object} target The activity, and the `sceneId` the narration is for
|
|
299
|
+
* @param {Object} script The narration: `items`, each with its `text`
|
|
300
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
301
|
+
*/
|
|
302
|
+
export declare const storeRunSceneAudio: (target: RunActivityTarget & {
|
|
303
|
+
sceneId: string;
|
|
304
|
+
}, script: {
|
|
305
|
+
items: {
|
|
306
|
+
text: string;
|
|
307
|
+
}[];
|
|
308
|
+
}, token: string) => Promise<RunSceneAudioStored>;
|
|
194
309
|
/**
|
|
195
310
|
* Get an integration agent's live health (cheap: deploy state + Cloud Run
|
|
196
311
|
* readiness; does not contact the agent). Use for the live status on the cards.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../../src/lib/integration.ts"],"names":[],"mappings":"AAuBA,UAAU,0BAA0B;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,OAAO,MAAM,KACZ,OAAO,CAAC,MAAM,CAoBhB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,IAAI,MAAM,EACV,OA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,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAC/C,QAAQ;IAAE,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,EACrC,OAAO,MAAM,KACZ,OAAO,CAAC,mBAAmB,CAY3B,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,IAAI,MAAM,EACV,OAAO,MAAM,KACZ,OAAO,CAAC,MAAM,CAgBhB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,IAAI,MAAM,EACV,OAAO,MAAM,KACZ,OAAO,CAAC,MAAM,CAiBhB,CAAC"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.testIntegrationHealth = exports.getIntegrationHealth = exports.
|
|
6
|
+
exports.testIntegrationHealth = exports.getIntegrationHealth = exports.storeRunSceneAudio = exports.storeRunMedia = exports.saveRunLearningContent = exports.deleteRunMicroSkills = exports.saveRunMicroSkill = exports.refundRunQuota = exports.consumeRunQuota = exports.updateRunNotification = exports.reportRunProgress = exports.RUN_LEARNING_CONTENT_TYPE = exports.RUN_NOTIFICATION_STATUS = exports.settleExecution = exports.heartbeatExecution = exports.claimExecution = exports.EXECUTION_OUTCOME = exports.getDeclarablePermissions = exports.getExecutionEnvelope = exports.setDefaultIntegration = exports.setIntegrationInformation = exports.publishIntegration = exports.getEnabledContentProviders = exports.getContentInformationByUrlFromBrowser = exports.getContentInformationByUrl = exports.getIntegrationsByCapability = exports.getIntegrationsList = exports.getIntegrationInformationById = exports.discardIntegrationChanges = exports.deleteIntegration = exports.createIntegration = void 0;
|
|
7
7
|
const axiosClient_js_1 = require("./axiosClient.js");
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const node_html_parser_1 = __importDefault(require("node-html-parser"));
|
|
@@ -358,7 +358,7 @@ exports.setDefaultIntegration = setDefaultIntegration;
|
|
|
358
358
|
* resolved configuration, the identity to act as). Called by the agent runtime
|
|
359
359
|
* in run-once mode with the token the execution was started with.
|
|
360
360
|
* @param {String} batchJobId The event record the execution was started for
|
|
361
|
-
* @param {String} token The
|
|
361
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
362
362
|
*/
|
|
363
363
|
const getExecutionEnvelope = (batchJobId, token) => {
|
|
364
364
|
return new Promise((resolve, reject) => {
|
|
@@ -396,15 +396,17 @@ const getDeclarablePermissions = (token) => {
|
|
|
396
396
|
});
|
|
397
397
|
};
|
|
398
398
|
exports.getDeclarablePermissions = getDeclarablePermissions;
|
|
399
|
-
/** The request header an agent returns its run ticket in. */
|
|
400
|
-
exports.RUN_TICKET_HEADER = "x-stackfactor-run-ticket";
|
|
401
399
|
/** How an execution settles its run. */
|
|
402
400
|
exports.EXECUTION_OUTCOME = {
|
|
403
401
|
COMPLETED: 2,
|
|
404
402
|
FAILED: 3,
|
|
405
403
|
};
|
|
406
|
-
|
|
407
|
-
|
|
404
|
+
/**
|
|
405
|
+
* A run's calls carry one credential: the AGENT token the platform minted for
|
|
406
|
+
* it, which names the run — so no call here says which run it is.
|
|
407
|
+
*/
|
|
408
|
+
const lifecycleHeaders = (token) => ({
|
|
409
|
+
headers: { authorization: token },
|
|
408
410
|
});
|
|
409
411
|
/**
|
|
410
412
|
* Resolves the lifecycle answer whether the platform said yes (200) or "not
|
|
@@ -427,23 +429,20 @@ const lifecycleAnswer = (request, resolve, reject) => {
|
|
|
427
429
|
* An execution claiming its run, once: PENDING → RUNNING. Of however many
|
|
428
430
|
* executions the transport may start for one run, exactly one claim answers
|
|
429
431
|
* `claimed: true`; the others get `claimed: false` and should exit without
|
|
430
|
-
* doing the work. Which run is never sent: the run
|
|
431
|
-
* the agent runtime at start, with the token the execution was started with
|
|
432
|
-
*
|
|
433
|
-
* @param {String} token The execution's token
|
|
434
|
-
* @param {String} runTicket The ticket from this run's envelope
|
|
432
|
+
* doing the work. Which run is never sent: the run's token names it. Called by
|
|
433
|
+
* the agent runtime at start, with the token the execution was started with.
|
|
434
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
435
435
|
*/
|
|
436
|
-
const claimExecution = (token
|
|
436
|
+
const claimExecution = (token) => new Promise((resolve, reject) => lifecycleAnswer(axiosClient_js_1.client.post("/api/v1/integrations/executions/claim", {}, lifecycleHeaders(token)), resolve, reject));
|
|
437
437
|
exports.claimExecution = claimExecution;
|
|
438
438
|
/**
|
|
439
439
|
* An execution keeping its run alive. Called on a fast cadence (~30 s) while
|
|
440
440
|
* the handler runs, so a run that stops beating is known to be abandoned.
|
|
441
|
-
* @param {String} token The
|
|
442
|
-
* @param {String} runTicket The ticket from this run's envelope
|
|
441
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
443
442
|
*/
|
|
444
|
-
const heartbeatExecution = (token
|
|
443
|
+
const heartbeatExecution = (token) => {
|
|
445
444
|
return new Promise((resolve, reject) => {
|
|
446
|
-
const request = axiosClient_js_1.client.post("/api/v1/integrations/executions/heartbeat", {}, lifecycleHeaders(token
|
|
445
|
+
const request = axiosClient_js_1.client.post("/api/v1/integrations/executions/heartbeat", {}, lifecycleHeaders(token));
|
|
447
446
|
request
|
|
448
447
|
.then(() => resolve())
|
|
449
448
|
.catch((error) => reject(error));
|
|
@@ -456,36 +455,151 @@ exports.heartbeatExecution = heartbeatExecution;
|
|
|
456
455
|
* platform's sweeper got there first) and the outcome was not recorded.
|
|
457
456
|
* @param {Number} status EXECUTION_OUTCOME.COMPLETED or FAILED
|
|
458
457
|
* @param {*} outcome A result summary, or the error — kept on the run's record
|
|
459
|
-
* @param {String} token The
|
|
460
|
-
* @param {String} runTicket The ticket from this run's envelope
|
|
458
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
461
459
|
*/
|
|
462
|
-
const settleExecution = (status, outcome, token
|
|
460
|
+
const settleExecution = (status, outcome, token) => new Promise((resolve, reject) => lifecycleAnswer(axiosClient_js_1.client.post("/api/v1/integrations/executions/settle", { status, outcome: outcome ?? null }, lifecycleHeaders(token)), resolve, reject));
|
|
463
461
|
exports.settleExecution = settleExecution;
|
|
462
|
+
// ── A run's own state while it runs ─────────────────────────────────────
|
|
463
|
+
//
|
|
464
|
+
// What an agent run changes about itself: progress, its notification, the
|
|
465
|
+
// generation quota it spends and the micro-skills of the learning content it
|
|
466
|
+
// generates. Every call needs the run's AGENT token (the one the execution was
|
|
467
|
+
// started with — never a person's session), which names the run, and the
|
|
468
|
+
// platform answers for that one run only: nothing here names a batch job,
|
|
469
|
+
// notification, quota record or learning content. The integration
|
|
470
|
+
// must declare the matching permission, and the tenant must have accepted it:
|
|
471
|
+
// progress, notification System - Update Own Run State
|
|
472
|
+
// quota System - Manage Own Run Quota
|
|
473
|
+
// micro-skills System - Manage Own Run Micro-Skills
|
|
474
|
+
// learning content, media, audio
|
|
475
|
+
// System - Manage Own Run Learning Content
|
|
476
|
+
/** Notification statuses a run may move its own notification to. */
|
|
477
|
+
exports.RUN_NOTIFICATION_STATUS = {
|
|
478
|
+
INPROGRESS: 5,
|
|
479
|
+
COMPLETED: 6,
|
|
480
|
+
FAILED: 7,
|
|
481
|
+
};
|
|
482
|
+
/** What a run may save its learning content as. */
|
|
483
|
+
exports.RUN_LEARNING_CONTENT_TYPE = {
|
|
484
|
+
VIDEO: 2,
|
|
485
|
+
TEXT_CONTENT: 3,
|
|
486
|
+
};
|
|
487
|
+
/** The media types a run may store, and the file name each is sent under. */
|
|
488
|
+
const RUN_MEDIA_FILE_NAMES = {
|
|
489
|
+
"image/jpeg": "media.jpg",
|
|
490
|
+
"image/png": "media.png",
|
|
491
|
+
"video/mp4": "media.mp4",
|
|
492
|
+
};
|
|
493
|
+
const runStateCall = (request) => new Promise((resolve, reject) => {
|
|
494
|
+
request
|
|
495
|
+
.then((response) => resolve(response.data))
|
|
496
|
+
.catch((error) => reject(error));
|
|
497
|
+
});
|
|
464
498
|
/**
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
* @param {String} token The
|
|
471
|
-
* service account's, holding Admin - Read Own Integration Settings)
|
|
472
|
-
* @param {String} runTicket The ticket from this run's envelope
|
|
499
|
+
* Reports how far the run got, with log lines; kept on the run's record (the
|
|
500
|
+
* newest 200 lines).
|
|
501
|
+
* @param {Number} percent 0–100
|
|
502
|
+
* @param {String|null} message A one-line summary, e.g. "micro-skill 4 of 10"
|
|
503
|
+
* @param {RunLogLine[]} log Up to 50 lines
|
|
504
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
473
505
|
*/
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
506
|
+
const reportRunProgress = (percent, message, log, token) => runStateCall(axiosClient_js_1.client.post("/api/v1/integrations/executions/progress", { percent, message, log }, lifecycleHeaders(token)));
|
|
507
|
+
exports.reportRunProgress = reportRunProgress;
|
|
508
|
+
/**
|
|
509
|
+
* Moves the run's own notification to in progress, completed or failed, with
|
|
510
|
+
* the details the person sees. Resolves `cancelled: true` when the person
|
|
511
|
+
* cancelled it — the notification is left as they left it and the run should
|
|
512
|
+
* stop, clean up and settle.
|
|
513
|
+
* @param {Number} status A RUN_NOTIFICATION_STATUS value
|
|
514
|
+
* @param {*} details What the notification shows: progress, log, …
|
|
515
|
+
* @param {String|null} description Replaces the notification's text; null keeps it
|
|
516
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
517
|
+
*/
|
|
518
|
+
const updateRunNotification = (status, details, description, token) => runStateCall(axiosClient_js_1.client.post("/api/v1/integrations/executions/notification", { status, details: details ?? null, description }, lifecycleHeaders(token)));
|
|
519
|
+
exports.updateRunNotification = updateRunNotification;
|
|
520
|
+
/**
|
|
521
|
+
* Consumes generation quota (a GENERATE_* type) for the person the run acts
|
|
522
|
+
* for. Rejects with 400 QUOTA_EXCEEDED when fewer than `amount` remain.
|
|
523
|
+
* @param {String} type e.g. "GENERATE_LEARNING_CONTENT"
|
|
524
|
+
* @param {Number} amount 1–100
|
|
525
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
526
|
+
*/
|
|
527
|
+
const consumeRunQuota = (type, amount, token) => runStateCall(axiosClient_js_1.client.post("/api/v1/integrations/executions/quota/consume", { type, amount }, lifecycleHeaders(token)));
|
|
528
|
+
exports.consumeRunQuota = consumeRunQuota;
|
|
529
|
+
/**
|
|
530
|
+
* Refunds quota this same run consumed and has not refunded yet — never more;
|
|
531
|
+
* a larger refund rejects with 422.
|
|
532
|
+
* @param {String} type The type the run consumed
|
|
533
|
+
* @param {Number} amount 1–100
|
|
534
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
535
|
+
*/
|
|
536
|
+
const refundRunQuota = (type, amount, token) => runStateCall(axiosClient_js_1.client.post("/api/v1/integrations/executions/quota/refund", { type, amount }, lifecycleHeaders(token)));
|
|
537
|
+
exports.refundRunQuota = refundRunQuota;
|
|
538
|
+
/**
|
|
539
|
+
* Saves a micro-skill of the learning content the run was started for — a new
|
|
540
|
+
* one, or a new draft of one it has. The parent does not need to exist yet.
|
|
541
|
+
* @param {Object} microSkill `microSkillId` plus learning activities, objectives, …
|
|
542
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
543
|
+
*/
|
|
544
|
+
const saveRunMicroSkill = (microSkill, token) => runStateCall(axiosClient_js_1.client.put("/api/v1/integrations/executions/microskills", microSkill, lifecycleHeaders(token)));
|
|
545
|
+
exports.saveRunMicroSkill = saveRunMicroSkill;
|
|
546
|
+
/**
|
|
547
|
+
* Deletes a micro-skill of the run's learning content by its record id, or all
|
|
548
|
+
* of them when `id` is null — what a cancelled or failed run cleans up.
|
|
549
|
+
* @param {String|null} id The micro-skill record's id, or null for all
|
|
550
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
551
|
+
*/
|
|
552
|
+
const deleteRunMicroSkills = (id, token) => runStateCall(axiosClient_js_1.client.delete(id
|
|
553
|
+
? `/api/v1/integrations/executions/microskills/${encodeURIComponent(id)}`
|
|
554
|
+
: "/api/v1/integrations/executions/microskills", lifecycleHeaders(token)));
|
|
555
|
+
exports.deleteRunMicroSkills = deleteRunMicroSkills;
|
|
556
|
+
/**
|
|
557
|
+
* Saves the learning content the run was started for, as video or text
|
|
558
|
+
* content, with the settings it was generated with. It is recorded as the work
|
|
559
|
+
* of the person the run acts for. Save it once its micro-skills are stored.
|
|
560
|
+
* @param {Number} type A RUN_LEARNING_CONTENT_TYPE value
|
|
561
|
+
* @param {Object|null} settings The generation settings; null keeps the defaults
|
|
562
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
563
|
+
*/
|
|
564
|
+
const saveRunLearningContent = (type, settings, token) => runStateCall(axiosClient_js_1.client.put("/api/v1/integrations/executions/learning-content", { type, settings }, lifecycleHeaders(token)));
|
|
565
|
+
exports.saveRunLearningContent = saveRunLearningContent;
|
|
566
|
+
/**
|
|
567
|
+
* Stores an image or a video clip of one of the run's learning activities
|
|
568
|
+
* (PNG, JPEG or MP4, up to 100 MB). Any other type rejects with 400.
|
|
569
|
+
* @param {Object} target The activity, and the `mediaId` the file is stored as
|
|
570
|
+
* @param {Blob|Uint8Array} media The file's bytes (a Buffer is a Uint8Array)
|
|
571
|
+
* @param {String} mimeType "image/png", "image/jpeg" or "video/mp4"
|
|
572
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
573
|
+
*/
|
|
574
|
+
const storeRunMedia = (target, media, mimeType, token) => {
|
|
575
|
+
const formData = new FormData();
|
|
576
|
+
formData.append("microSkillId", target.microSkillId);
|
|
577
|
+
formData.append("learningActivityId", target.learningActivityId);
|
|
578
|
+
formData.append("mediaId", target.mediaId);
|
|
579
|
+
formData.append("file", new Blob([media], { type: mimeType }), RUN_MEDIA_FILE_NAMES[mimeType] ?? "media.bin");
|
|
580
|
+
return runStateCall(axiosClient_js_1.client.put("/api/v1/integrations/executions/media", formData, {
|
|
581
|
+
headers: {
|
|
582
|
+
authorization: token,
|
|
583
|
+
"Content-Type": "multipart/form-data",
|
|
584
|
+
},
|
|
585
|
+
}));
|
|
487
586
|
};
|
|
488
|
-
exports.
|
|
587
|
+
exports.storeRunMedia = storeRunMedia;
|
|
588
|
+
/**
|
|
589
|
+
* Has the platform synthesise the narration of one scene of one of the run's
|
|
590
|
+
* video activities and store it where the player reads it. Resolves
|
|
591
|
+
* `stored: false` when there was nothing to store.
|
|
592
|
+
* @param {Object} target The activity, and the `sceneId` the narration is for
|
|
593
|
+
* @param {Object} script The narration: `items`, each with its `text`
|
|
594
|
+
* @param {String} token The run's AGENT token (it names the run)
|
|
595
|
+
*/
|
|
596
|
+
const storeRunSceneAudio = (target, script, token) => runStateCall(axiosClient_js_1.client.post("/api/v1/integrations/executions/audio", {
|
|
597
|
+
microSkillId: target.microSkillId,
|
|
598
|
+
learningActivityId: target.learningActivityId,
|
|
599
|
+
sceneId: target.sceneId,
|
|
600
|
+
script,
|
|
601
|
+
}, lifecycleHeaders(token)));
|
|
602
|
+
exports.storeRunSceneAudio = storeRunSceneAudio;
|
|
489
603
|
/**
|
|
490
604
|
* Get an integration agent's live health (cheap: deploy state + Cloud Run
|
|
491
605
|
* readiness; does not contact the agent). Use for the live status on the cards.
|