@segmentstream/agent 0.39.0 → 0.40.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/README.md +4 -12
- package/dist/_chunks/{build-metadata-CwWzry8P.mjs → build-metadata-BZlbshZq.mjs} +1 -1
- package/dist/extension/config.d.ts +8 -12
- package/dist/extension/config.mjs +25 -17
- package/dist/extension/conventions.d.ts +23 -0
- package/dist/extension/conventions.mjs +48 -0
- package/dist/extension/instructions/persona.mjs +3 -3
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.mjs +1 -1
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/lifecycle.mjs +1 -1
- package/dist/extension/personas.d.ts +14 -13
- package/dist/extension/personas.mjs +22 -33
- package/package.json +1 -5
- package/raw.d.ts +0 -9
package/README.md
CHANGED
|
@@ -131,18 +131,10 @@ platform's deployment manifest.
|
|
|
131
131
|
The shared instructions (`agent/agent/instructions.md`) reach everyone the agent talks to. A
|
|
132
132
|
persona, `agent/personas/<name>.md`, says who the agent is to the person in a conversation: one
|
|
133
133
|
per conversation, the first `personas.byRole` entry whose role the person who started it holds,
|
|
134
|
-
else `personas.default`.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
/// <reference types="@segmentstream/agent/raw" />
|
|
139
|
-
import { segmentstream } from "@segmentstream/agent/extension";
|
|
140
|
-
|
|
141
|
-
import config from "../../segmentstream.json";
|
|
142
|
-
import seller from "../../personas/seller.md?raw";
|
|
143
|
-
|
|
144
|
-
export default segmentstream({ ...config, files: { "personas/seller.md": seller } });
|
|
145
|
-
```
|
|
134
|
+
else `personas.default`. The SDK reads each text when the agent is built and the platform puts it
|
|
135
|
+
inline when it deploys, so the mount stays `segmentstream(config)`; the build fails when a named
|
|
136
|
+
text is missing. Guidance for the group decision model lives the same way in
|
|
137
|
+
`agent/groups/instructions.md`, after the platform's rules.
|
|
146
138
|
|
|
147
139
|
Skills stay eve's, in `agent/agent/skills/`. A module there that exports
|
|
148
140
|
`forRoles(["accountant", "founder"], { description, content })` is a skill only those roles get:
|
|
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
|
|
|
4
4
|
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
|
-
var version = "0.
|
|
7
|
+
var version = "0.40.0";
|
|
8
8
|
function agentBuild(environment = process.env) {
|
|
9
9
|
return {
|
|
10
10
|
agent: version,
|
|
@@ -163,17 +163,14 @@ export interface SegmentStreamAgentConfigInput {
|
|
|
163
163
|
/**
|
|
164
164
|
* What the agent is to the person in a session: a persona per role, the first role the person
|
|
165
165
|
* who started the session holds winning in the order written, and a `default` for everyone else.
|
|
166
|
-
* Each persona's text is `agent/personas/<name>.md
|
|
166
|
+
* Each persona's text is `agent/personas/<name>.md`; the SDK and the platform put it in
|
|
167
|
+
* `texts`, which is not written by hand.
|
|
167
168
|
*/
|
|
168
169
|
readonly personas?: {
|
|
169
170
|
readonly byRole?: Readonly<Record<string, string>>;
|
|
170
171
|
readonly default?: string;
|
|
172
|
+
readonly texts?: Readonly<Record<string, string>>;
|
|
171
173
|
};
|
|
172
|
-
/**
|
|
173
|
-
* The persona texts, by path beside `segmentstream.json`. Only the mount passes them, imported
|
|
174
|
-
* with `?raw`, because eve reads no directory at runtime.
|
|
175
|
-
*/
|
|
176
|
-
readonly files?: Readonly<Record<string, string>>;
|
|
177
174
|
}
|
|
178
175
|
export interface TelegramSettings {
|
|
179
176
|
readonly groups?: {
|
|
@@ -238,10 +235,8 @@ export interface SegmentStreamAgentConfig extends AdmissionSettings {
|
|
|
238
235
|
/** Whether the sandbox file tools are on; see {@link SegmentStreamAgentConfigInput.sandbox}. */
|
|
239
236
|
readonly sandbox: boolean;
|
|
240
237
|
readonly sessions: SessionSettings;
|
|
241
|
-
/** The personas; absent when `segmentstream.json` declares none. */
|
|
238
|
+
/** The personas, with their texts once read; absent when `segmentstream.json` declares none. */
|
|
242
239
|
readonly personas?: PersonaSettings;
|
|
243
|
-
/** The persona texts the mount passes; absent when validating the JSON alone. */
|
|
244
|
-
readonly files?: Readonly<Record<string, string>>;
|
|
245
240
|
}
|
|
246
241
|
/** One validation failure, in Standard Schema's issue shape. */
|
|
247
242
|
export interface ConfigIssue {
|
|
@@ -294,10 +289,11 @@ export declare function isLegacyAgentArchive(version: string | undefined): boole
|
|
|
294
289
|
export declare function validateConfig(input: unknown, options?: {
|
|
295
290
|
readonly archiveSdkVersion?: string;
|
|
296
291
|
/**
|
|
297
|
-
* Whether the
|
|
298
|
-
*
|
|
292
|
+
* Whether the texts of the conventional files must be inline, as when the mount validates
|
|
293
|
+
* (see {@link configSchema}) or the platform validates a deployment's archive after putting
|
|
294
|
+
* them inline. Validating the JSON alone, as {@link manifestOf} does, leaves them out.
|
|
299
295
|
*/
|
|
300
|
-
readonly
|
|
296
|
+
readonly texts?: "required";
|
|
301
297
|
}): Validation;
|
|
302
298
|
/**
|
|
303
299
|
* The Standard Schema eve validates the mount with. `types` exists only for type inference, as the
|
|
@@ -9,7 +9,8 @@ import { localizedText as localizedText$1 } from "./lib/admission.mjs";
|
|
|
9
9
|
import { STRUCTURED_KINDS } from "./lib/telegram/structured-settings.mjs";
|
|
10
10
|
import { TELEGRAM_TEXT_KEYS } from "./lib/telegram/texts.mjs";
|
|
11
11
|
import { isTechnicalText } from "./lib/customer-text-safety.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { inlineConventionFiles } from "./conventions.mjs";
|
|
13
|
+
import { personaSettings } from "./personas.mjs";
|
|
13
14
|
import { readFileSync, realpathSync } from "node:fs";
|
|
14
15
|
import { expandGroupFiles, groupPolicyIssues } from "@segmentstream/ontology/groups";
|
|
15
16
|
import { TELEGRAM_LINK_PREVIEWS, isHttpOrigin } from "@segmentstream/ontology/telegram";
|
|
@@ -59,7 +60,15 @@ function configWarnings(value) {
|
|
|
59
60
|
...inapplicableGroupThresholds(root?.groups).map((path) => ({
|
|
60
61
|
path: ["groups", ...path],
|
|
61
62
|
message: INAPPLICABLE_THRESHOLD
|
|
62
|
-
}))
|
|
63
|
+
})),
|
|
64
|
+
...isRecord(root?.groups) && isRecord(root.groups.smart) && root.groups.smart.instructions !== void 0 ? [{
|
|
65
|
+
path: [
|
|
66
|
+
"groups",
|
|
67
|
+
"smart",
|
|
68
|
+
"instructions"
|
|
69
|
+
],
|
|
70
|
+
message: "is deprecated: write the decision model's guidance in agent/groups/instructions.md, which the platform adds after its own rules, and remove this setting"
|
|
71
|
+
}] : []
|
|
63
72
|
];
|
|
64
73
|
}
|
|
65
74
|
var SegmentStreamAgentConfigError = class extends Error {
|
|
@@ -585,8 +594,7 @@ function validateConfig(input, options = {}) {
|
|
|
585
594
|
"limits",
|
|
586
595
|
"replies",
|
|
587
596
|
"texts",
|
|
588
|
-
"personas"
|
|
589
|
-
"files"
|
|
597
|
+
"personas"
|
|
590
598
|
],
|
|
591
599
|
issues
|
|
592
600
|
});
|
|
@@ -767,16 +775,7 @@ function validateConfig(input, options = {}) {
|
|
|
767
775
|
message: "must be true or false",
|
|
768
776
|
path: ["sandbox"]
|
|
769
777
|
});
|
|
770
|
-
const personas = personaSettings(root?.personas, issues);
|
|
771
|
-
const files = options.mount === true ? bundledFiles({
|
|
772
|
-
value: root?.files,
|
|
773
|
-
personas,
|
|
774
|
-
issues
|
|
775
|
-
}) : void 0;
|
|
776
|
-
if (options.mount !== true && root?.files !== void 0) issues.push({
|
|
777
|
-
message: "is passed by agent/agent/extensions/segmentstream.ts, not set in segmentstream.json",
|
|
778
|
-
path: ["files"]
|
|
779
|
-
});
|
|
778
|
+
const personas = personaSettings(root?.personas, issues, options.texts === "required");
|
|
780
779
|
if (issues.length > 0) return { issues };
|
|
781
780
|
return { value: {
|
|
782
781
|
groups,
|
|
@@ -802,14 +801,23 @@ function validateConfig(input, options = {}) {
|
|
|
802
801
|
limits,
|
|
803
802
|
replies,
|
|
804
803
|
texts,
|
|
805
|
-
...personas === null ? {} : { personas }
|
|
806
|
-
...files === void 0 || Object.keys(files).length === 0 ? {} : { files }
|
|
804
|
+
...personas === null ? {} : { personas }
|
|
807
805
|
} };
|
|
808
806
|
}
|
|
807
|
+
function readAgentFile(path) {
|
|
808
|
+
try {
|
|
809
|
+
const root = realpathSync(process.cwd());
|
|
810
|
+
const file = realpathSync(resolve(root, path));
|
|
811
|
+
const local = relative(root, file);
|
|
812
|
+
return local.startsWith("..") || isAbsolute(local) ? void 0 : readFileSync(file, "utf8");
|
|
813
|
+
} catch {
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
809
817
|
const configSchema = { "~standard": {
|
|
810
818
|
version: 1,
|
|
811
819
|
vendor: "segmentstream",
|
|
812
|
-
validate: (input) => validateConfig(input, {
|
|
820
|
+
validate: (input) => validateConfig(inlineConventionFiles(input, readAgentFile), { texts: "required" }),
|
|
813
821
|
types: void 0
|
|
814
822
|
} };
|
|
815
823
|
function manifestOf(config) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The texts a workspace keeps in files beside `agent/segmentstream.json`, at fixed paths, so the
|
|
3
|
+
* JSON holds only choices and numbers:
|
|
4
|
+
*
|
|
5
|
+
* - `agent/personas/<persona>.md`: the text of each persona `personas` names;
|
|
6
|
+
* - `agent/groups/instructions.md`: guidance the group decision model reads after the platform's
|
|
7
|
+
* rules.
|
|
8
|
+
*
|
|
9
|
+
* The SDK reads them when the agent is built; the platform reads them from the deployment's
|
|
10
|
+
* archive and puts them inline in `segmentstream.json` before it builds, so the running agent,
|
|
11
|
+
* which has no files, reads the same texts.
|
|
12
|
+
*/
|
|
13
|
+
/** Guidance for the group decision model, appended to the platform's rules. */
|
|
14
|
+
export declare const GROUP_INSTRUCTIONS_FILE = "groups/instructions.md";
|
|
15
|
+
/** Reads a file by its path under `agent/`; `undefined` when there is none. */
|
|
16
|
+
export type AgentFileReader = (path: string) => string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* `agent/segmentstream.json` with the conventional files' texts inline: each persona's text in
|
|
19
|
+
* `personas.texts`, and `agent/groups/instructions.md` as `groups.smart.instructions.append`. A
|
|
20
|
+
* file that exists wins over an inline value; without the file, an inline value, such as the one
|
|
21
|
+
* the platform wrote at deploy, stays. Anything that is not an object is returned as it is.
|
|
22
|
+
*/
|
|
23
|
+
export declare function inlineConventionFiles(input: unknown, read: AgentFileReader): unknown;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { fileURLToPath as __eveFileURLToPath } from "node:url";
|
|
2
|
+
import { dirname as __eveDirname } from "node:path";
|
|
3
|
+
import { createRequire as __eveCreateRequire } from "node:module";
|
|
4
|
+
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
|
+
__eveDirname(__filename);
|
|
6
|
+
__eveCreateRequire(import.meta.url);
|
|
7
|
+
import { isPersonaName, personaFile } from "./personas.mjs";
|
|
8
|
+
const GROUP_INSTRUCTIONS_FILE = "groups/instructions.md";
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
function inlineConventionFiles(input, read) {
|
|
13
|
+
if (!isRecord(input)) return input;
|
|
14
|
+
let output = { ...input };
|
|
15
|
+
const guidance = read(GROUP_INSTRUCTIONS_FILE);
|
|
16
|
+
if (guidance !== void 0) {
|
|
17
|
+
const groups = isRecord(input.groups) ? input.groups : {};
|
|
18
|
+
const smart = isRecord(groups.smart) ? groups.smart : {};
|
|
19
|
+
output = {
|
|
20
|
+
...output,
|
|
21
|
+
groups: {
|
|
22
|
+
...groups,
|
|
23
|
+
smart: {
|
|
24
|
+
...smart,
|
|
25
|
+
instructions: { append: guidance }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (isRecord(input.personas)) {
|
|
31
|
+
const personas = input.personas;
|
|
32
|
+
const named = [...isRecord(personas.byRole) ? Object.values(personas.byRole) : [], personas.default].filter(isPersonaName);
|
|
33
|
+
const texts = isRecord(personas.texts) ? { ...personas.texts } : {};
|
|
34
|
+
for (const name of new Set(named)) {
|
|
35
|
+
const text = read(personaFile(name));
|
|
36
|
+
if (text !== void 0) texts[name] = text;
|
|
37
|
+
}
|
|
38
|
+
output = {
|
|
39
|
+
...output,
|
|
40
|
+
personas: {
|
|
41
|
+
...personas,
|
|
42
|
+
...Object.keys(texts).length === 0 ? {} : { texts }
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return output;
|
|
47
|
+
}
|
|
48
|
+
export { GROUP_INSTRUCTIONS_FILE, inlineConventionFiles };
|
|
@@ -6,13 +6,13 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
8
|
import { a as rolesOf } from "../../_chunks/principal-BIX7T6Hh.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { personaFor } from "../personas.mjs";
|
|
10
10
|
import { defineDynamic, defineInstructions } from "eve/instructions";
|
|
11
11
|
var persona_default = defineDynamic((context) => {
|
|
12
|
-
const { personas
|
|
12
|
+
const { personas } = segmentstream.config;
|
|
13
13
|
if (personas === void 0) return null;
|
|
14
14
|
const persona = personaFor(personas, rolesOf(context.session.auth.initiator ?? context.session.auth.current));
|
|
15
|
-
const content = persona === void 0 ? void 0 :
|
|
15
|
+
const content = persona === void 0 ? void 0 : personas.texts?.[persona];
|
|
16
16
|
return content === void 0 ? null : defineInstructions({
|
|
17
17
|
role: "system",
|
|
18
18
|
content
|
|
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
|
|
|
4
4
|
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
|
-
export { t as agentBuild } from "../../_chunks/build-metadata-
|
|
7
|
+
export { t as agentBuild } from "../../_chunks/build-metadata-BZlbshZq.mjs";
|
|
@@ -10,7 +10,7 @@ import { groupRoutingHealth } from "../group-routing/health.mjs";
|
|
|
10
10
|
import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
|
|
11
11
|
import { handleWorkspaceCallback, isWorkspaceCallback } from "./callbacks.mjs";
|
|
12
12
|
import { telegramText, withTelegramTexts } from "./texts.mjs";
|
|
13
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
13
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-BZlbshZq.mjs";
|
|
14
14
|
import { attachmentLifecycle } from "./lifecycle.mjs";
|
|
15
15
|
import { manifestOf } from "../../config.mjs";
|
|
16
16
|
import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
|
|
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
|
|
|
4
4
|
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
7
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-BZlbshZq.mjs";
|
|
8
8
|
import { runtimeRequestFailure } from "./runtime-request.mjs";
|
|
9
9
|
import { GET } from "eve/channels";
|
|
10
10
|
const HEALTH_ROUTE = "/eve/v1/telegram/health";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { d as telegramRuntimeSource, l as principalRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-BIX7T6Hh.mjs";
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-BZlbshZq.mjs";
|
|
9
9
|
import { n as currentInboundRequest } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
|
|
10
10
|
import { object } from "../confirmation-description.mjs";
|
|
11
11
|
import { needsConfirmation } from "../confirmations.mjs";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Personas: what the agent is to the person in a conversation. `agent/segmentstream.json` says
|
|
3
|
-
* which roles get which persona; each text is `agent/personas/<
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* so a session keeps one persona.
|
|
3
|
+
* which roles get which persona; each persona's text is `agent/personas/<persona>.md`, which the
|
|
4
|
+
* SDK reads when the agent is built and the platform puts inline (`personas.texts`) when it
|
|
5
|
+
* deploys, so the running agent, which has no files, reads the same text. Selection reads only the
|
|
6
|
+
* roles of the person who started the session, so a session keeps one persona.
|
|
7
7
|
*/
|
|
8
8
|
/** The directory beside `segmentstream.json` that holds the persona texts. */
|
|
9
9
|
export declare const PERSONAS_DIRECTORY = "personas";
|
|
@@ -12,6 +12,11 @@ export interface PersonaSettings {
|
|
|
12
12
|
readonly byRole: Readonly<Record<string, string>>;
|
|
13
13
|
/** The persona of anyone no role matches, including a person who holds no roles. */
|
|
14
14
|
readonly default?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Each persona's text, from `agent/personas/<persona>.md`. The SDK fills it when the agent is
|
|
17
|
+
* built and the platform when it deploys; it is not written by hand.
|
|
18
|
+
*/
|
|
19
|
+
readonly texts?: Readonly<Record<string, string>>;
|
|
15
20
|
}
|
|
16
21
|
/** One validation failure, in Standard Schema's issue shape. */
|
|
17
22
|
interface Issue {
|
|
@@ -24,15 +29,11 @@ export declare function personaFile(name: string): string;
|
|
|
24
29
|
export declare function personaNames(settings: PersonaSettings | null): ReadonlyArray<string>;
|
|
25
30
|
/** The persona for a person with `roles`: the first `byRole` entry they hold, or the default. */
|
|
26
31
|
export declare function personaFor(settings: PersonaSettings | null, roles: ReadonlyArray<string>): string | undefined;
|
|
27
|
-
/**
|
|
28
|
-
export declare function
|
|
32
|
+
/** Whether a value is a persona name, safe as a file name under `agent/personas/`. */
|
|
33
|
+
export declare function isPersonaName(value: unknown): value is string;
|
|
29
34
|
/**
|
|
30
|
-
* Validates
|
|
31
|
-
* is
|
|
35
|
+
* Validates `personas` of `agent/segmentstream.json`; `null` when absent. With `requireTexts`, as
|
|
36
|
+
* when the agent is built or deployed, every persona it names needs its text.
|
|
32
37
|
*/
|
|
33
|
-
export declare function
|
|
34
|
-
readonly value: unknown;
|
|
35
|
-
readonly personas: PersonaSettings | null;
|
|
36
|
-
readonly issues: Issue[];
|
|
37
|
-
}): Readonly<Record<string, string>>;
|
|
38
|
+
export declare function personaSettings(value: unknown, issues: Issue[], requireTexts?: boolean): PersonaSettings | null;
|
|
38
39
|
export {};
|
|
@@ -23,13 +23,16 @@ function personaFor(settings, roles) {
|
|
|
23
23
|
function isRecord(value) {
|
|
24
24
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
25
|
}
|
|
26
|
+
function isPersonaName(value) {
|
|
27
|
+
return validName(value);
|
|
28
|
+
}
|
|
26
29
|
function validName(value) {
|
|
27
30
|
return typeof value === "string" && value.length <= MAXIMUM_NAME_LENGTH && NAME.test(value);
|
|
28
31
|
}
|
|
29
32
|
function role(value) {
|
|
30
33
|
return typeof value === "string" && value.trim() !== "" && value.trim() === value;
|
|
31
34
|
}
|
|
32
|
-
function personaSettings(value, issues) {
|
|
35
|
+
function personaSettings(value, issues, requireTexts = false) {
|
|
33
36
|
const path = ["personas"];
|
|
34
37
|
if (value === void 0) return null;
|
|
35
38
|
if (!isRecord(value)) {
|
|
@@ -39,7 +42,7 @@ function personaSettings(value, issues) {
|
|
|
39
42
|
});
|
|
40
43
|
return null;
|
|
41
44
|
}
|
|
42
|
-
for (const key of Object.keys(value)) if (key !== "byRole" && key !== "default") issues.push({
|
|
45
|
+
for (const key of Object.keys(value)) if (key !== "byRole" && key !== "default" && key !== "texts") issues.push({
|
|
43
46
|
message: "is not a known setting",
|
|
44
47
|
path: [...path, key]
|
|
45
48
|
});
|
|
@@ -75,40 +78,26 @@ function personaSettings(value, issues) {
|
|
|
75
78
|
message: "needs byRole, default or both",
|
|
76
79
|
path
|
|
77
80
|
});
|
|
78
|
-
|
|
81
|
+
const settings = {
|
|
79
82
|
byRole,
|
|
80
83
|
...typeof value.default === "string" && validName(value.default) ? { default: value.default } : {}
|
|
81
84
|
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
const texts = {};
|
|
86
|
+
if (value.texts !== void 0 && !isRecord(value.texts)) issues.push({
|
|
87
|
+
message: "must be an object of persona to text",
|
|
88
|
+
path: [...path, "texts"]
|
|
89
|
+
});
|
|
90
|
+
for (const name of personaNames(settings)) {
|
|
91
|
+
const text = isRecord(value.texts) ? value.texts[name] : void 0;
|
|
92
|
+
if (typeof text === "string" && text.trim() !== "") texts[name] = text;
|
|
93
|
+
else if (requireTexts) issues.push({
|
|
94
|
+
message: `has no text: write it in agent/${personaFile(name)}`,
|
|
95
|
+
path: [...path, name]
|
|
91
96
|
});
|
|
92
|
-
return files;
|
|
93
97
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
else files[file] = content;
|
|
99
|
-
const expected = new Set(personaNames(input.personas).map(personaFile));
|
|
100
|
-
for (const file of expected) if (files[file] === void 0) issues.push({
|
|
101
|
-
message: `is missing: import agent/${file} with ?raw in agent/agent/extensions/segmentstream.ts and pass it under files["${file}"]`,
|
|
102
|
-
path: [...path, file]
|
|
103
|
-
});
|
|
104
|
-
else if (files[file].trim() === "") issues.push({
|
|
105
|
-
message: "is empty",
|
|
106
|
-
path: [...path, file]
|
|
107
|
-
});
|
|
108
|
-
for (const file of Object.keys(files)) if (!expected.has(file)) issues.push({
|
|
109
|
-
message: "is not a persona that segmentstream.json names",
|
|
110
|
-
path: [...path, file]
|
|
111
|
-
});
|
|
112
|
-
return files;
|
|
98
|
+
return Object.keys(texts).length === 0 ? settings : {
|
|
99
|
+
...settings,
|
|
100
|
+
texts
|
|
101
|
+
};
|
|
113
102
|
}
|
|
114
|
-
export { PERSONAS_DIRECTORY,
|
|
103
|
+
export { PERSONAS_DIRECTORY, isPersonaName, personaFile, personaFor, personaNames, personaSettings };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"description": "Mount a SegmentStream workspace's agent on eve: the ontology as tools, acting as the member who writes, and Telegram, WhatsApp and Slack through the workspace's connections.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|
|
@@ -31,9 +31,6 @@
|
|
|
31
31
|
"types": "./dist/extension/extension.d.ts",
|
|
32
32
|
"default": "./dist/extension/extension.mjs"
|
|
33
33
|
},
|
|
34
|
-
"./raw": {
|
|
35
|
-
"types": "./raw.d.ts"
|
|
36
|
-
},
|
|
37
34
|
"./sandbox": {
|
|
38
35
|
"types": "./dist/extension/lib/sandbox.d.ts",
|
|
39
36
|
"default": "./dist/extension/lib/sandbox.mjs"
|
|
@@ -59,7 +56,6 @@
|
|
|
59
56
|
},
|
|
60
57
|
"files": [
|
|
61
58
|
"dist",
|
|
62
|
-
"raw.d.ts",
|
|
63
59
|
"README.md",
|
|
64
60
|
"LICENSE",
|
|
65
61
|
"NOTICE"
|
package/raw.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Text imports for the persona files the mount passes as `files`: eve embeds a
|
|
3
|
-
* file imported with `?raw` as its UTF-8 text. Reference it from the mount with
|
|
4
|
-
* `/// <reference types="@segmentstream/agent/raw" />`.
|
|
5
|
-
*/
|
|
6
|
-
declare module "*.md?raw" {
|
|
7
|
-
const text: string;
|
|
8
|
-
export default text;
|
|
9
|
-
}
|