@scout9/app 1.0.0-alpha.0.1.94 → 1.0.0-alpha.0.1.96
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/dev-ecdbe765.cjs +48120 -0
- package/dist/index-ea1273a0.cjs +44421 -0
- package/dist/index.cjs +66 -164
- package/dist/{multipart-parser-bbe3e14d.cjs → multipart-parser-26f98006.cjs} +20 -20
- package/dist/testing-tools.cjs +21 -31
- package/package.json +1 -1
- package/src/core/templates/app.js +7 -3
- package/src/runtime/index.js +0 -1
- package/src/runtime/macros/builder.js +4 -3
- package/src/runtime/macros/event.js +3 -3
- package/types/index.d.ts +118 -0
- package/types/index.d.ts.map +16 -3
- package/dist/exports-1f0580dd.cjs +0 -92387
- package/src/runtime/entry.js +0 -92
package/dist/index.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var index = require("./index-ea1273a0.cjs");
|
|
6
|
+
var dev = require("./dev-ecdbe765.cjs");
|
|
6
7
|
var spirits = require("./spirits-32395ac4.cjs");
|
|
7
|
-
require('node:readline');
|
|
8
8
|
require('fs');
|
|
9
9
|
require('events');
|
|
10
10
|
require('path');
|
|
@@ -14,9 +14,6 @@ require('util');
|
|
|
14
14
|
require('assert');
|
|
15
15
|
require('buffer');
|
|
16
16
|
require('zlib');
|
|
17
|
-
require('url');
|
|
18
|
-
require('fs/promises');
|
|
19
|
-
require('string_decoder');
|
|
20
17
|
require('node:fs');
|
|
21
18
|
require('node:fs/promises');
|
|
22
19
|
require('node:path');
|
|
@@ -26,172 +23,77 @@ require('node:https');
|
|
|
26
23
|
require('node:zlib');
|
|
27
24
|
require('node:stream');
|
|
28
25
|
require('node:buffer');
|
|
26
|
+
require('string_decoder');
|
|
27
|
+
require('node:util');
|
|
28
|
+
require('node:net');
|
|
29
|
+
require('node:readline');
|
|
30
|
+
require('node:os');
|
|
31
|
+
require('fs/promises');
|
|
29
32
|
require('http');
|
|
30
33
|
require('https');
|
|
34
|
+
require('url');
|
|
31
35
|
require('tty');
|
|
32
36
|
require('os');
|
|
33
37
|
require('crypto');
|
|
34
38
|
require('node:process');
|
|
35
|
-
require('node:os');
|
|
36
|
-
require('node:util');
|
|
37
|
-
require('node:net');
|
|
38
|
-
require('node:vm');
|
|
39
|
-
|
|
40
|
-
var MacroGlobals = /*#__PURE__*/function () {
|
|
41
|
-
function MacroGlobals() {
|
|
42
|
-
spirits._classCallCheck(this, MacroGlobals);
|
|
43
|
-
}
|
|
44
|
-
spirits._createClass(MacroGlobals, null, [{
|
|
45
|
-
key: "$convo",
|
|
46
|
-
value: function $convo() {
|
|
47
|
-
var _globalThis$SCOUT;
|
|
48
|
-
var $convo = globalThis === null || globalThis === void 0 || (_globalThis$SCOUT = globalThis.SCOUT9) === null || _globalThis$SCOUT === void 0 ? void 0 : _globalThis$SCOUT.$convo;
|
|
49
|
-
if (!$convo) {
|
|
50
|
-
throw new Error("$convo not found in runtime context, ".concat(spirits._classStaticPrivateFieldSpecGet(MacroGlobals, MacroGlobals, _hint)));
|
|
51
|
-
}
|
|
52
|
-
return $convo;
|
|
53
|
-
}
|
|
54
|
-
}]);
|
|
55
|
-
return MacroGlobals;
|
|
56
|
-
}();
|
|
57
|
-
var _hint = {
|
|
58
|
-
writable: true,
|
|
59
|
-
value: "make sure the context is properly instantiated before running workflow."
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
function handleAxiosResponse(res) {
|
|
63
|
-
if (res.status === 200) {
|
|
64
|
-
return res.data;
|
|
65
|
-
} else {
|
|
66
|
-
throw new Error("".concat(res.status, " ").concat(res.statusText));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
39
|
|
|
70
|
-
/**
|
|
71
|
-
* The `did` macro takes a given prompt and infers a binary `true` or `false` result in relation to the prompt's subject actor and the prompt's inquiry.
|
|
72
|
-
* @param {string} prompt
|
|
73
|
-
* @return {Promise<boolean>}
|
|
74
|
-
*/
|
|
75
|
-
function did(_x) {
|
|
76
|
-
return _did.apply(this, arguments);
|
|
77
|
-
}
|
|
78
40
|
|
|
79
|
-
/**
|
|
80
|
-
* The `context` macro, similar to the `did` macro, takes a natural statement and checks the entire conversation state and extracts or infers a metadata composition result.
|
|
81
|
-
* @param {string} prompt
|
|
82
|
-
* @param {import('@scout9/admin').CaptureContextRequestExamples} [examples]
|
|
83
|
-
* @return {Promise<import('@scout9/admin').CaptureContext200Response>}
|
|
84
|
-
*/
|
|
85
|
-
function _did() {
|
|
86
|
-
_did = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee(prompt) {
|
|
87
|
-
var convoId, _yield$Scout9Api$did$, value;
|
|
88
|
-
return spirits._regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
89
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
90
|
-
case 0:
|
|
91
|
-
convoId = MacroGlobals.$convo();
|
|
92
|
-
_context2.next = 3;
|
|
93
|
-
return new exports$1.build.Scout9Api(new exports$1.build.Configuration({
|
|
94
|
-
apiKey: process.env.SCOUT9_API_KEY
|
|
95
|
-
})).did({
|
|
96
|
-
prompt: prompt,
|
|
97
|
-
convoId: convoId
|
|
98
|
-
}).then(handleAxiosResponse);
|
|
99
|
-
case 3:
|
|
100
|
-
_yield$Scout9Api$did$ = _context2.sent;
|
|
101
|
-
value = _yield$Scout9Api$did$.value;
|
|
102
|
-
return _context2.abrupt("return", value);
|
|
103
|
-
case 6:
|
|
104
|
-
case "end":
|
|
105
|
-
return _context2.stop();
|
|
106
|
-
}
|
|
107
|
-
}, _callee);
|
|
108
|
-
}));
|
|
109
|
-
return _did.apply(this, arguments);
|
|
110
|
-
}
|
|
111
|
-
function context(_x2, _x3) {
|
|
112
|
-
return _context.apply(this, arguments);
|
|
113
|
-
}
|
|
114
|
-
function _context() {
|
|
115
|
-
_context = spirits._asyncToGenerator( /*#__PURE__*/spirits._regeneratorRuntime().mark(function _callee2(prompt, examples) {
|
|
116
|
-
var convoId;
|
|
117
|
-
return spirits._regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
118
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
119
|
-
case 0:
|
|
120
|
-
convoId = MacroGlobals.$convo();
|
|
121
|
-
_context3.next = 3;
|
|
122
|
-
return new exports$1.build.Scout9Api(new exports$1.build.Configuration({
|
|
123
|
-
apiKey: process.env.SCOUT9_API_KEY
|
|
124
|
-
})).captureContext({
|
|
125
|
-
prompt: prompt,
|
|
126
|
-
examples: examples,
|
|
127
|
-
convoId: convoId
|
|
128
|
-
}).then(handleAxiosResponse);
|
|
129
|
-
case 3:
|
|
130
|
-
return _context3.abrupt("return", _context3.sent);
|
|
131
|
-
case 4:
|
|
132
|
-
case "end":
|
|
133
|
-
return _context3.stop();
|
|
134
|
-
}
|
|
135
|
-
}, _callee2);
|
|
136
|
-
}));
|
|
137
|
-
return _context.apply(this, arguments);
|
|
138
|
-
}
|
|
139
41
|
|
|
140
|
-
exports.
|
|
141
|
-
exports.
|
|
142
|
-
exports.
|
|
143
|
-
exports.
|
|
144
|
-
exports.
|
|
145
|
-
exports.
|
|
146
|
-
exports.
|
|
147
|
-
exports.
|
|
148
|
-
exports.
|
|
149
|
-
exports.
|
|
150
|
-
exports.
|
|
151
|
-
exports.
|
|
152
|
-
exports.
|
|
153
|
-
exports.
|
|
154
|
-
exports.
|
|
155
|
-
exports.
|
|
156
|
-
exports.
|
|
157
|
-
exports.
|
|
158
|
-
exports.
|
|
159
|
-
exports.
|
|
160
|
-
exports.
|
|
161
|
-
exports.
|
|
162
|
-
exports.
|
|
163
|
-
exports.
|
|
164
|
-
exports.
|
|
165
|
-
exports.
|
|
166
|
-
exports.
|
|
167
|
-
exports.
|
|
168
|
-
exports.
|
|
169
|
-
exports.
|
|
170
|
-
exports.
|
|
171
|
-
exports.
|
|
172
|
-
exports.
|
|
173
|
-
exports.
|
|
174
|
-
exports.
|
|
175
|
-
exports.
|
|
176
|
-
exports.
|
|
177
|
-
exports.
|
|
178
|
-
exports.
|
|
179
|
-
exports.
|
|
180
|
-
exports.
|
|
181
|
-
exports.
|
|
182
|
-
exports.
|
|
183
|
-
exports.
|
|
184
|
-
exports.
|
|
185
|
-
exports.
|
|
186
|
-
exports.
|
|
187
|
-
exports.
|
|
188
|
-
exports.
|
|
189
|
-
exports.
|
|
190
|
-
exports.
|
|
191
|
-
exports.
|
|
192
|
-
exports.
|
|
193
|
-
exports.
|
|
194
|
-
exports.
|
|
42
|
+
exports.context = index.context;
|
|
43
|
+
exports.did = index.did;
|
|
44
|
+
exports.json = index.json;
|
|
45
|
+
exports.run = index.run;
|
|
46
|
+
exports.sendEvent = index.sendEvent;
|
|
47
|
+
exports.ContextExampleSchema = dev.ContextExampleSchema;
|
|
48
|
+
exports.ContextExampleWithTrainingDataSchema = dev.ContextExampleWithTrainingDataSchema;
|
|
49
|
+
exports.ConversationContext = dev.ConversationContext;
|
|
50
|
+
exports.ConversationSchema = dev.ConversationSchema;
|
|
51
|
+
exports.EventResponse = dev.EventResponse;
|
|
52
|
+
exports.FollowupBaseSchema = dev.FollowupBaseSchema;
|
|
53
|
+
exports.FollowupSchema = dev.FollowupSchema;
|
|
54
|
+
exports.ForwardSchema = dev.ForwardSchema;
|
|
55
|
+
exports.InstructionObjectSchema = dev.InstructionObjectSchema;
|
|
56
|
+
exports.InstructionSchema = dev.InstructionSchema;
|
|
57
|
+
exports.IntentWorkflowEventSchema = dev.IntentWorkflowEventSchema;
|
|
58
|
+
exports.MessageSchema = dev.MessageSchema;
|
|
59
|
+
exports.Scout9ProjectBuildConfigSchema = dev.Scout9ProjectBuildConfigSchema;
|
|
60
|
+
exports.Scout9ProjectConfigSchema = dev.Scout9ProjectConfigSchema;
|
|
61
|
+
exports.Scout9Test = dev.Scout9Test;
|
|
62
|
+
exports.WorkflowConfigurationSchema = dev.WorkflowConfigurationSchema;
|
|
63
|
+
exports.WorkflowEventSchema = dev.WorkflowEventSchema;
|
|
64
|
+
exports.WorkflowFunctionSchema = dev.WorkflowFunctionSchema;
|
|
65
|
+
exports.WorkflowResponseMessage = dev.WorkflowResponseMessage;
|
|
66
|
+
exports.WorkflowResponseMessageApiRequest = dev.WorkflowResponseMessageApiRequest;
|
|
67
|
+
exports.WorkflowResponseMessageApiResponse = dev.WorkflowResponseMessageApiResponse;
|
|
68
|
+
exports.WorkflowResponseSchema = dev.WorkflowResponseSchema;
|
|
69
|
+
exports.WorkflowResponseSlotBaseSchema = dev.WorkflowResponseSlotBaseSchema;
|
|
70
|
+
exports.WorkflowResponseSlotSchema = dev.WorkflowResponseSlotSchema;
|
|
71
|
+
exports.WorkflowsConfigurationSchema = dev.WorkflowsConfigurationSchema;
|
|
72
|
+
exports.agentBaseConfigurationSchema = dev.agentBaseConfigurationSchema;
|
|
73
|
+
exports.agentConfigurationSchema = dev.agentConfigurationSchema;
|
|
74
|
+
exports.agentsBaseConfigurationSchema = dev.agentsBaseConfigurationSchema;
|
|
75
|
+
exports.agentsConfigurationSchema = dev.agentsConfigurationSchema;
|
|
76
|
+
exports.apiFunctionSchema = dev.apiFunctionSchema;
|
|
77
|
+
exports.createMockAgent = dev.createMockAgent;
|
|
78
|
+
exports.createMockConversation = dev.createMockConversation;
|
|
79
|
+
exports.createMockCustomer = dev.createMockCustomer;
|
|
80
|
+
exports.createMockMessage = dev.createMockMessage;
|
|
81
|
+
exports.createMockWorkflowEvent = dev.createMockWorkflowEvent;
|
|
82
|
+
exports.customerSchema = dev.customerSchema;
|
|
83
|
+
exports.customerValueSchema = dev.customerValueSchema;
|
|
84
|
+
exports.deleteApiFunctionSchema = dev.deleteApiFunctionSchema;
|
|
85
|
+
exports.entitiesRootConfigurationSchema = dev.entitiesRootConfigurationSchema;
|
|
86
|
+
exports.entitiesRootProjectConfigurationSchema = dev.entitiesRootProjectConfigurationSchema;
|
|
87
|
+
exports.entityApiConfigurationSchema = dev.entityApiConfigurationSchema;
|
|
88
|
+
exports.entityConfigurationSchema = dev.entityConfigurationSchema;
|
|
89
|
+
exports.entityRootProjectConfigurationSchema = dev.entityRootProjectConfigurationSchema;
|
|
90
|
+
exports.eventResponseSchema = dev.eventResponseSchema;
|
|
91
|
+
exports.forward = dev.forward;
|
|
92
|
+
exports.getApiFunctionSchema = dev.getApiFunctionSchema;
|
|
93
|
+
exports.instruct = dev.instruct;
|
|
94
|
+
exports.patchApiFunctionSchema = dev.patchApiFunctionSchema;
|
|
95
|
+
exports.postApiFunctionSchema = dev.postApiFunctionSchema;
|
|
96
|
+
exports.putApiFunctionSchema = dev.putApiFunctionSchema;
|
|
97
|
+
exports.queryApiFunctionSchema = dev.queryApiFunctionSchema;
|
|
98
|
+
exports.reply = dev.reply;
|
|
195
99
|
exports.Spirits = spirits.Spirits;
|
|
196
|
-
exports.context = context;
|
|
197
|
-
exports.did = did;
|
|
@@ -2,38 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
require('node:fs');
|
|
4
4
|
require('node:path');
|
|
5
|
-
var
|
|
5
|
+
var index = require("./index-ea1273a0.cjs");
|
|
6
6
|
require("./spirits-32395ac4.cjs");
|
|
7
|
-
require(
|
|
8
|
-
require('fs');
|
|
9
|
-
require('events');
|
|
10
|
-
require('path');
|
|
11
|
-
require('constants');
|
|
12
|
-
require('stream');
|
|
7
|
+
require("./dev-ecdbe765.cjs");
|
|
13
8
|
require('util');
|
|
9
|
+
require('stream');
|
|
10
|
+
require('path');
|
|
11
|
+
require('http');
|
|
12
|
+
require('https');
|
|
13
|
+
require('url');
|
|
14
|
+
require('fs');
|
|
14
15
|
require('assert');
|
|
15
|
-
require('
|
|
16
|
+
require('tty');
|
|
17
|
+
require('os');
|
|
16
18
|
require('zlib');
|
|
17
|
-
require('
|
|
19
|
+
require('events');
|
|
20
|
+
require('crypto');
|
|
21
|
+
require('node:fs/promises');
|
|
18
22
|
require('fs/promises');
|
|
19
23
|
require('string_decoder');
|
|
20
|
-
require('node:
|
|
24
|
+
require('node:readline');
|
|
25
|
+
require('node:process');
|
|
21
26
|
require('node:url');
|
|
27
|
+
require('node:os');
|
|
28
|
+
require('constants');
|
|
29
|
+
require('buffer');
|
|
22
30
|
require('node:http');
|
|
23
31
|
require('node:https');
|
|
24
32
|
require('node:zlib');
|
|
25
33
|
require('node:stream');
|
|
26
34
|
require('node:buffer');
|
|
27
|
-
require('http');
|
|
28
|
-
require('https');
|
|
29
|
-
require('tty');
|
|
30
|
-
require('os');
|
|
31
|
-
require('crypto');
|
|
32
|
-
require('node:process');
|
|
33
|
-
require('node:os');
|
|
34
35
|
require('node:util');
|
|
35
36
|
require('node:net');
|
|
36
|
-
require('node:vm');
|
|
37
37
|
|
|
38
38
|
let s = 0;
|
|
39
39
|
const S = {
|
|
@@ -348,7 +348,7 @@ async function toFormData(Body, ct) {
|
|
|
348
348
|
let contentType;
|
|
349
349
|
let filename;
|
|
350
350
|
const entryChunks = [];
|
|
351
|
-
const formData = new
|
|
351
|
+
const formData = new index.FormData();
|
|
352
352
|
const onPartData = ui8a => {
|
|
353
353
|
entryValue += decoder.decode(ui8a, {
|
|
354
354
|
stream: true
|
|
@@ -358,7 +358,7 @@ async function toFormData(Body, ct) {
|
|
|
358
358
|
entryChunks.push(ui8a);
|
|
359
359
|
};
|
|
360
360
|
const appendFileToFormData = () => {
|
|
361
|
-
const file = new
|
|
361
|
+
const file = new index.File(entryChunks, filename, {
|
|
362
362
|
type: contentType
|
|
363
363
|
});
|
|
364
364
|
formData.append(entryName, file);
|
package/dist/testing-tools.cjs
CHANGED
|
@@ -2,47 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var dev = require("./dev-ecdbe765.cjs");
|
|
6
6
|
var spirits = require("./spirits-32395ac4.cjs");
|
|
7
|
-
require('node:readline');
|
|
8
|
-
require('fs');
|
|
9
|
-
require('events');
|
|
10
|
-
require('path');
|
|
11
|
-
require('constants');
|
|
12
|
-
require('stream');
|
|
13
7
|
require('util');
|
|
14
|
-
require('
|
|
15
|
-
require('
|
|
16
|
-
require('zlib');
|
|
17
|
-
require('url');
|
|
18
|
-
require('fs/promises');
|
|
19
|
-
require('string_decoder');
|
|
20
|
-
require('node:fs');
|
|
21
|
-
require('node:fs/promises');
|
|
22
|
-
require('node:path');
|
|
23
|
-
require('node:url');
|
|
24
|
-
require('node:http');
|
|
25
|
-
require('node:https');
|
|
26
|
-
require('node:zlib');
|
|
27
|
-
require('node:stream');
|
|
28
|
-
require('node:buffer');
|
|
8
|
+
require('stream');
|
|
9
|
+
require('path');
|
|
29
10
|
require('http');
|
|
30
11
|
require('https');
|
|
12
|
+
require('url');
|
|
13
|
+
require('fs');
|
|
14
|
+
require('assert');
|
|
31
15
|
require('tty');
|
|
32
16
|
require('os');
|
|
17
|
+
require('zlib');
|
|
18
|
+
require('events');
|
|
33
19
|
require('crypto');
|
|
20
|
+
require('node:fs');
|
|
21
|
+
require('node:path');
|
|
22
|
+
require('node:fs/promises');
|
|
23
|
+
require('fs/promises');
|
|
24
|
+
require('string_decoder');
|
|
25
|
+
require('node:readline');
|
|
34
26
|
require('node:process');
|
|
27
|
+
require('node:url');
|
|
35
28
|
require('node:os');
|
|
36
|
-
require('node:util');
|
|
37
|
-
require('node:net');
|
|
38
|
-
require('node:vm');
|
|
39
29
|
|
|
40
30
|
|
|
41
31
|
|
|
42
|
-
exports.Scout9Test =
|
|
43
|
-
exports.createMockAgent =
|
|
44
|
-
exports.createMockConversation =
|
|
45
|
-
exports.createMockCustomer =
|
|
46
|
-
exports.createMockMessage =
|
|
47
|
-
exports.createMockWorkflowEvent =
|
|
32
|
+
exports.Scout9Test = dev.Scout9Test;
|
|
33
|
+
exports.createMockAgent = dev.createMockAgent;
|
|
34
|
+
exports.createMockConversation = dev.createMockConversation;
|
|
35
|
+
exports.createMockCustomer = dev.createMockCustomer;
|
|
36
|
+
exports.createMockMessage = dev.createMockMessage;
|
|
37
|
+
exports.createMockWorkflowEvent = dev.createMockWorkflowEvent;
|
|
48
38
|
exports.Spirits = spirits.Spirits;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import bodyParser from 'body-parser';
|
|
|
5
5
|
import colors from 'kleur';
|
|
6
6
|
import { config as dotenv } from 'dotenv';
|
|
7
7
|
import { Configuration, Scout9Api } from '@scout9/admin';
|
|
8
|
-
import { EventResponse } from '@scout9/app';
|
|
8
|
+
import { EventResponse, WorkflowEventSchema } from '@scout9/app';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import https from 'node:https';
|
|
@@ -162,8 +162,12 @@ if (dev) {
|
|
|
162
162
|
// Root application POST endpoint will run the scout9 app
|
|
163
163
|
app.post(dev ? '/dev/workflow' : '/', async (req, res) => {
|
|
164
164
|
try {
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
const event = WorkflowEventSchema.parse(req.body.event);
|
|
166
|
+
globalThis.SCOUT9 = {
|
|
167
|
+
...event,
|
|
168
|
+
$convo: req.body.$convo,
|
|
169
|
+
}
|
|
170
|
+
const response = await projectApp(event);
|
|
167
171
|
res.writeHead(200, {'Content-Type': 'application/json'});
|
|
168
172
|
res.end(JSON.stringify(response));
|
|
169
173
|
} catch (e) {
|
package/src/runtime/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Builder Macros
|
|
3
3
|
* used to build and guide a application logic in relation to the Scout9 conversation state.
|
|
4
4
|
*/
|
|
5
|
-
import { Configuration, Scout9Api } from '@scout9/admin';
|
|
5
|
+
import { Configuration, MacroContextResult, Scout9Api } from '@scout9/admin';
|
|
6
6
|
import MacroGlobals from './globals.js';
|
|
7
7
|
|
|
8
8
|
function handleAxiosResponse(res) {
|
|
@@ -30,14 +30,15 @@ export async function did(prompt) {
|
|
|
30
30
|
* The `context` macro, similar to the `did` macro, takes a natural statement and checks the entire conversation state and extracts or infers a metadata composition result.
|
|
31
31
|
* @param {string} prompt
|
|
32
32
|
* @param {import('@scout9/admin').CaptureContextRequestExamples} [examples]
|
|
33
|
-
* @return {Promise<import('@scout9/admin').
|
|
33
|
+
* @return {Promise<import('@scout9/admin').MacroContextValue>}
|
|
34
34
|
*/
|
|
35
35
|
export async function context(prompt, examples) {
|
|
36
36
|
const convoId = MacroGlobals.$convo();
|
|
37
|
-
|
|
37
|
+
const {value} = (await (new Scout9Api(new Configuration({apiKey: process.env.SCOUT9_API_KEY}))).captureContext({
|
|
38
38
|
prompt,
|
|
39
39
|
examples,
|
|
40
40
|
convoId
|
|
41
41
|
})
|
|
42
42
|
.then(handleAxiosResponse));
|
|
43
|
+
return value;
|
|
43
44
|
}
|
|
@@ -92,7 +92,7 @@ function EventMacros() {
|
|
|
92
92
|
* @param {object} no - The object to process if the instruction is a string and the condition is not met.
|
|
93
93
|
*
|
|
94
94
|
* @overload
|
|
95
|
-
* @param {(Array<
|
|
95
|
+
* @param {(Array<IWorkflowResponseSlotBase & {keywords: string[]}>)} instruction
|
|
96
96
|
*
|
|
97
97
|
* @return {EventMacros}
|
|
98
98
|
*/
|
|
@@ -213,8 +213,8 @@ function EventMacros() {
|
|
|
213
213
|
return this;
|
|
214
214
|
},
|
|
215
215
|
/**
|
|
216
|
-
*
|
|
217
|
-
* @return {Array<
|
|
216
|
+
* Returns event payload
|
|
217
|
+
* @return {Array<IWorkflowResponseSlot>}
|
|
218
218
|
*/
|
|
219
219
|
toJSON(flush = true) {
|
|
220
220
|
if (flush) {
|
package/types/index.d.ts
CHANGED
|
@@ -20039,6 +20039,124 @@ declare module '@scout9/app' {
|
|
|
20039
20039
|
body: Partial<RequestBody>;
|
|
20040
20040
|
}) => Promise<EventResponse<Response>>;
|
|
20041
20041
|
export type IDeleteApiFunction<Params, Response_1> = IApiFunction<Params, Response>;
|
|
20042
|
+
export function instruct(instruction: string, options?: {
|
|
20043
|
+
id?: string | undefined;
|
|
20044
|
+
persist?: string | undefined;
|
|
20045
|
+
} | undefined): typeof EventMacros;
|
|
20046
|
+
/**
|
|
20047
|
+
* This macro ends the conversation and forwards it the owner of the persona to manually handle the flow. If your app returns undefined or no event, then a default forward is generated.
|
|
20048
|
+
* @param message - the message to forward to owner of persona
|
|
20049
|
+
* */
|
|
20050
|
+
export function forward(message: string, options?: {
|
|
20051
|
+
mode?: "after-reply" | "immediately" | undefined;
|
|
20052
|
+
to?: string | undefined;
|
|
20053
|
+
} | undefined): any;
|
|
20054
|
+
/**
|
|
20055
|
+
* If a manual message must be sent, you can use the `reply` macro
|
|
20056
|
+
* @param message - the message to manually send to the user
|
|
20057
|
+
* */
|
|
20058
|
+
export function reply(message: string, options?: {
|
|
20059
|
+
scheduled?: string | Date | undefined;
|
|
20060
|
+
delay?: string | undefined;
|
|
20061
|
+
} | undefined): any;
|
|
20062
|
+
function EventMacros(): {
|
|
20063
|
+
/**
|
|
20064
|
+
* Sets context into the conversation context for later use
|
|
20065
|
+
* */
|
|
20066
|
+
upsert(updates: Record<string, any>): any;
|
|
20067
|
+
/**
|
|
20068
|
+
* Similar to `instruction` except that it requires a schedule time parameter that determines when to follow up (and is not an event output macro). This will fire another run job with a new insert system context message, if `options.literal` is set to true, it will be an appended agent message prior to running the workflow app.
|
|
20069
|
+
*
|
|
20070
|
+
* */
|
|
20071
|
+
/**
|
|
20072
|
+
* Similar to `instruction` except that it requires a schedule time parameter that determines when to follow up (and is not an event output macro). This will fire another run job with a new insert system context message, if `options.literal` is set to true, it will be an appended agent message prior to running the workflow app.
|
|
20073
|
+
*
|
|
20074
|
+
* */
|
|
20075
|
+
followup(options: Date | string): any;
|
|
20076
|
+
/**
|
|
20077
|
+
* Similar to `instruction` except that it requires a schedule time parameter that determines when to follow up (and is not an event output macro). This will fire another run job with a new insert system context message, if `options.literal` is set to true, it will be an appended agent message prior to running the workflow app.
|
|
20078
|
+
*
|
|
20079
|
+
* */
|
|
20080
|
+
/**
|
|
20081
|
+
* Similar to `instruction` except that it requires a schedule time parameter that determines when to follow up (and is not an event output macro). This will fire another run job with a new insert system context message, if `options.literal` is set to true, it will be an appended agent message prior to running the workflow app.
|
|
20082
|
+
*
|
|
20083
|
+
* */
|
|
20084
|
+
followup(options: {
|
|
20085
|
+
scheduled: Date | string;
|
|
20086
|
+
cancelIf?: Record<string, any> | undefined;
|
|
20087
|
+
literal?: boolean | undefined;
|
|
20088
|
+
overrideLock?: boolean | undefined;
|
|
20089
|
+
}): any;
|
|
20090
|
+
/**
|
|
20091
|
+
* Similar to `instruct` except that it requires a schedule time parameter that determines when to follow up (and is not an event output macro). This will fire another run job with a new insert system context message, if `options.literal` is set to true, it will be an appended agent message prior to running the workflow app.
|
|
20092
|
+
* */
|
|
20093
|
+
/**
|
|
20094
|
+
* Similar to `instruct` except that it requires a schedule time parameter that determines when to follow up (and is not an event output macro). This will fire another run job with a new insert system context message, if `options.literal` is set to true, it will be an appended agent message prior to running the workflow app.
|
|
20095
|
+
* */
|
|
20096
|
+
anticipate(instruction: string, yes: object, no: object): any;
|
|
20097
|
+
/**
|
|
20098
|
+
* Similar to `instruct` except that it requires a schedule time parameter that determines when to follow up (and is not an event output macro). This will fire another run job with a new insert system context message, if `options.literal` is set to true, it will be an appended agent message prior to running the workflow app.
|
|
20099
|
+
* */
|
|
20100
|
+
/**
|
|
20101
|
+
* Similar to `instruct` except that it requires a schedule time parameter that determines when to follow up (and is not an event output macro). This will fire another run job with a new insert system context message, if `options.literal` is set to true, it will be an appended agent message prior to running the workflow app.
|
|
20102
|
+
* */
|
|
20103
|
+
anticipate(instruction: (Array<IWorkflowResponseSlotBase & {
|
|
20104
|
+
keywords: string[];
|
|
20105
|
+
}>)): typeof EventMacros;
|
|
20106
|
+
|
|
20107
|
+
instruct(instruction: string, options?: {
|
|
20108
|
+
id?: string | undefined;
|
|
20109
|
+
persist?: string | undefined;
|
|
20110
|
+
} | undefined): typeof EventMacros;
|
|
20111
|
+
/**
|
|
20112
|
+
* If a manual message must be sent, you can use the `reply` macro
|
|
20113
|
+
* @param message - the message to manually send to the user
|
|
20114
|
+
* */
|
|
20115
|
+
reply(message: string, options?: {
|
|
20116
|
+
scheduled?: string | Date | undefined;
|
|
20117
|
+
delay?: string | undefined;
|
|
20118
|
+
} | undefined): any;
|
|
20119
|
+
/**
|
|
20120
|
+
* This macro ends the conversation and forwards it the owner of the persona to manually handle the flow. If your app returns undefined or no event, then a default forward is generated.
|
|
20121
|
+
* @param message - the message to forward to owner of persona
|
|
20122
|
+
* */
|
|
20123
|
+
forward(message: string, options?: {
|
|
20124
|
+
mode?: "after-reply" | "immediately" | undefined;
|
|
20125
|
+
to?: string | undefined;
|
|
20126
|
+
} | undefined): any;
|
|
20127
|
+
/**
|
|
20128
|
+
* Returns event payload
|
|
20129
|
+
* */
|
|
20130
|
+
toJSON(flush?: boolean): Array<IWorkflowResponseSlot>;
|
|
20131
|
+
};
|
|
20132
|
+
/**
|
|
20133
|
+
* The `did` macro takes a given prompt and infers a binary `true` or `false` result in relation to the prompt's subject actor and the prompt's inquiry.
|
|
20134
|
+
* */
|
|
20135
|
+
export function did(prompt: string): Promise<boolean>;
|
|
20136
|
+
/**
|
|
20137
|
+
* The `context` macro, similar to the `did` macro, takes a natural statement and checks the entire conversation state and extracts or infers a metadata composition result.
|
|
20138
|
+
* */
|
|
20139
|
+
export function context(prompt: string, examples?: any): Promise<import('@scout9/admin').MacroContextValue>;
|
|
20140
|
+
export const ContextExampleWithTrainingDataSchema: z.ZodObject<{
|
|
20141
|
+
input: z.ZodString;
|
|
20142
|
+
output: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">;
|
|
20143
|
+
}, "strip", z.ZodTypeAny, {
|
|
20144
|
+
input: string;
|
|
20145
|
+
output: Record<string, any>[];
|
|
20146
|
+
}, {
|
|
20147
|
+
input: string;
|
|
20148
|
+
output: Record<string, any>[];
|
|
20149
|
+
}>;
|
|
20150
|
+
export const ContextExampleSchema: z.ZodUnion<[z.ZodArray<z.ZodObject<{
|
|
20151
|
+
input: z.ZodString;
|
|
20152
|
+
output: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">;
|
|
20153
|
+
}, "strip", z.ZodTypeAny, {
|
|
20154
|
+
input: string;
|
|
20155
|
+
output: Record<string, any>[];
|
|
20156
|
+
}, {
|
|
20157
|
+
input: string;
|
|
20158
|
+
output: Record<string, any>[];
|
|
20159
|
+
}>, "many">, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">]>;
|
|
20042
20160
|
}
|
|
20043
20161
|
|
|
20044
20162
|
declare module '@scout9/app/spirits' {
|