@manta-eu/client 0.1.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/LICENSE +21 -0
- package/dist/generated/graphql.d.ts +4719 -0
- package/dist/generated/graphql.d.ts.map +1 -0
- package/dist/generated/graphql.js +2452 -0
- package/dist/graphql-clients.d.ts +9 -0
- package/dist/graphql-clients.d.ts.map +1 -0
- package/dist/graphql-clients.js +27 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/shared/action-plan.d.ts +2 -0
- package/dist/shared/action-plan.d.ts.map +1 -0
- package/dist/shared/action-plan.js +1 -0
- package/dist/shared/agent-mode.d.ts +9 -0
- package/dist/shared/agent-mode.d.ts.map +1 -0
- package/dist/shared/agent-mode.js +38 -0
- package/dist/shared/agent-types.d.ts +41 -0
- package/dist/shared/agent-types.d.ts.map +1 -0
- package/dist/shared/agent-types.js +12 -0
- package/dist/shared/chat-context.d.ts +7 -0
- package/dist/shared/chat-context.d.ts.map +1 -0
- package/dist/shared/chat-context.js +38 -0
- package/dist/shared/chat-manager.d.ts +183 -0
- package/dist/shared/chat-manager.d.ts.map +1 -0
- package/dist/shared/chat-manager.js +75 -0
- package/dist/shared/chat-turn-errors.d.ts +16 -0
- package/dist/shared/chat-turn-errors.d.ts.map +1 -0
- package/dist/shared/chat-turn-errors.js +18 -0
- package/dist/shared/constants.d.ts +11 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +10 -0
- package/dist/shared/conversation-starter-defaults.d.ts +8 -0
- package/dist/shared/conversation-starter-defaults.d.ts.map +1 -0
- package/dist/shared/conversation-starter-defaults.js +20 -0
- package/dist/shared/datastore-id.d.ts +4 -0
- package/dist/shared/datastore-id.d.ts.map +1 -0
- package/dist/shared/datastore-id.js +17 -0
- package/dist/shared/datastore-path.d.ts +19 -0
- package/dist/shared/datastore-path.d.ts.map +1 -0
- package/dist/shared/datastore-path.js +62 -0
- package/dist/shared/datastore-route-table.d.ts +36 -0
- package/dist/shared/datastore-route-table.d.ts.map +1 -0
- package/dist/shared/datastore-route-table.js +43 -0
- package/dist/shared/duration.d.ts +6 -0
- package/dist/shared/duration.d.ts.map +1 -0
- package/dist/shared/duration.js +55 -0
- package/dist/shared/entity-set.d.ts +14 -0
- package/dist/shared/entity-set.d.ts.map +1 -0
- package/dist/shared/entity-set.js +25 -0
- package/dist/shared/error-utils.d.ts +23 -0
- package/dist/shared/error-utils.d.ts.map +1 -0
- package/dist/shared/error-utils.js +56 -0
- package/dist/shared/explorer-paths.d.ts +4 -0
- package/dist/shared/explorer-paths.d.ts.map +1 -0
- package/dist/shared/explorer-paths.js +7 -0
- package/dist/shared/fileIri.d.ts +12 -0
- package/dist/shared/fileIri.d.ts.map +1 -0
- package/dist/shared/fileIri.js +18 -0
- package/dist/shared/index.d.ts +22 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +8 -0
- package/dist/shared/live-context.d.ts +2 -0
- package/dist/shared/live-context.d.ts.map +1 -0
- package/dist/shared/live-context.js +15 -0
- package/dist/shared/maintenance-schedule.d.ts +11 -0
- package/dist/shared/maintenance-schedule.d.ts.map +1 -0
- package/dist/shared/maintenance-schedule.js +38 -0
- package/dist/shared/memory-citation-sampling.d.ts +16 -0
- package/dist/shared/memory-citation-sampling.d.ts.map +1 -0
- package/dist/shared/memory-citation-sampling.js +14 -0
- package/dist/shared/memory-confidence.d.ts +3 -0
- package/dist/shared/memory-confidence.d.ts.map +1 -0
- package/dist/shared/memory-confidence.js +7 -0
- package/dist/shared/memory-consolidation-limits.d.ts +6 -0
- package/dist/shared/memory-consolidation-limits.d.ts.map +1 -0
- package/dist/shared/memory-consolidation-limits.js +5 -0
- package/dist/shared/memory-dates.d.ts +3 -0
- package/dist/shared/memory-dates.d.ts.map +1 -0
- package/dist/shared/memory-dates.js +7 -0
- package/dist/shared/memory-decay.d.ts +22 -0
- package/dist/shared/memory-decay.d.ts.map +1 -0
- package/dist/shared/memory-decay.js +43 -0
- package/dist/shared/memory-diversity.d.ts +10 -0
- package/dist/shared/memory-diversity.d.ts.map +1 -0
- package/dist/shared/memory-diversity.js +44 -0
- package/dist/shared/memory-entity-recall.d.ts +8 -0
- package/dist/shared/memory-entity-recall.d.ts.map +1 -0
- package/dist/shared/memory-entity-recall.js +17 -0
- package/dist/shared/memory-importance.d.ts +4 -0
- package/dist/shared/memory-importance.d.ts.map +1 -0
- package/dist/shared/memory-importance.js +9 -0
- package/dist/shared/memory-keyword-recall.d.ts +13 -0
- package/dist/shared/memory-keyword-recall.d.ts.map +1 -0
- package/dist/shared/memory-keyword-recall.js +141 -0
- package/dist/shared/memory-kind-iris.d.ts +9 -0
- package/dist/shared/memory-kind-iris.d.ts.map +1 -0
- package/dist/shared/memory-kind-iris.js +22 -0
- package/dist/shared/memory-preload-gate.d.ts +37 -0
- package/dist/shared/memory-preload-gate.d.ts.map +1 -0
- package/dist/shared/memory-preload-gate.js +95 -0
- package/dist/shared/memory-sources.d.ts +3 -0
- package/dist/shared/memory-sources.d.ts.map +1 -0
- package/dist/shared/memory-sources.js +3 -0
- package/dist/shared/memory-teams.d.ts +2 -0
- package/dist/shared/memory-teams.d.ts.map +1 -0
- package/dist/shared/memory-teams.js +3 -0
- package/dist/shared/memory-token-budget.d.ts +8 -0
- package/dist/shared/memory-token-budget.d.ts.map +1 -0
- package/dist/shared/memory-token-budget.js +23 -0
- package/dist/shared/memory-volatility.d.ts +24 -0
- package/dist/shared/memory-volatility.d.ts.map +1 -0
- package/dist/shared/memory-volatility.js +55 -0
- package/dist/shared/message-utils.d.ts +12 -0
- package/dist/shared/message-utils.d.ts.map +1 -0
- package/dist/shared/message-utils.js +22 -0
- package/dist/shared/model.d.ts +165 -0
- package/dist/shared/model.d.ts.map +1 -0
- package/dist/shared/model.js +93 -0
- package/dist/shared/org-roles.d.ts +11 -0
- package/dist/shared/org-roles.d.ts.map +1 -0
- package/dist/shared/org-roles.js +10 -0
- package/dist/shared/page-context.d.ts +7 -0
- package/dist/shared/page-context.d.ts.map +1 -0
- package/dist/shared/page-context.js +1 -0
- package/dist/shared/permissions.d.ts +9 -0
- package/dist/shared/permissions.d.ts.map +1 -0
- package/dist/shared/permissions.js +10 -0
- package/dist/shared/questionnaire.d.ts +32 -0
- package/dist/shared/questionnaire.d.ts.map +1 -0
- package/dist/shared/questionnaire.js +68 -0
- package/dist/shared/rdf-namespaces.d.ts +11 -0
- package/dist/shared/rdf-namespaces.d.ts.map +1 -0
- package/dist/shared/rdf-namespaces.js +15 -0
- package/dist/shared/rule-iri.d.ts +4 -0
- package/dist/shared/rule-iri.d.ts.map +1 -0
- package/dist/shared/rule-iri.js +13 -0
- package/dist/shared/rule-search.d.ts +2 -0
- package/dist/shared/rule-search.d.ts.map +1 -0
- package/dist/shared/rule-search.js +1 -0
- package/dist/shared/session-types.d.ts +14 -0
- package/dist/shared/session-types.d.ts.map +1 -0
- package/dist/shared/session-types.js +1 -0
- package/dist/shared/spa-routes.d.ts +3 -0
- package/dist/shared/spa-routes.d.ts.map +1 -0
- package/dist/shared/spa-routes.js +5 -0
- package/dist/shared/stakeholder-iri.d.ts +7 -0
- package/dist/shared/stakeholder-iri.d.ts.map +1 -0
- package/dist/shared/stakeholder-iri.js +20 -0
- package/dist/shared/team-activation.d.ts +7 -0
- package/dist/shared/team-activation.d.ts.map +1 -0
- package/dist/shared/team-activation.js +3 -0
- package/dist/shared/team.d.ts +150 -0
- package/dist/shared/team.d.ts.map +1 -0
- package/dist/shared/team.js +88 -0
- package/dist/shared/tools/coercers.d.ts +6 -0
- package/dist/shared/tools/coercers.d.ts.map +1 -0
- package/dist/shared/tools/coercers.js +63 -0
- package/dist/shared/tools/index.d.ts +4 -0
- package/dist/shared/tools/index.d.ts.map +1 -0
- package/dist/shared/tools/index.js +2 -0
- package/dist/shared/tools/metadata.d.ts +12 -0
- package/dist/shared/tools/metadata.d.ts.map +1 -0
- package/dist/shared/tools/metadata.js +215 -0
- package/dist/shared/tools/test-triple.d.ts +16 -0
- package/dist/shared/tools/test-triple.d.ts.map +1 -0
- package/dist/shared/tools/test-triple.js +26 -0
- package/dist/shared/tools/types.d.ts +236 -0
- package/dist/shared/tools/types.d.ts.map +1 -0
- package/dist/shared/tools/types.js +1 -0
- package/dist/shared/upload.d.ts +26 -0
- package/dist/shared/upload.d.ts.map +1 -0
- package/dist/shared/upload.js +26 -0
- package/dist/shared/website-url.d.ts +5 -0
- package/dist/shared/website-url.d.ts.map +1 -0
- package/dist/shared/website-url.js +31 -0
- package/dist/shared/workspace-artifacts.d.ts +21 -0
- package/dist/shared/workspace-artifacts.d.ts.map +1 -0
- package/dist/shared/workspace-artifacts.js +59 -0
- package/dist/shared/writable-shape-query.d.ts +2 -0
- package/dist/shared/writable-shape-query.d.ts.map +1 -0
- package/dist/shared/writable-shape-query.js +21 -0
- package/dist/types/jsonld.d.ts +2 -0
- package/dist/types/jsonld.d.ts.map +1 -0
- package/dist/types/jsonld.js +1 -0
- package/dist/types/sparql-types.d.ts +3 -0
- package/dist/types/sparql-types.d.ts.map +1 -0
- package/dist/types/sparql-types.js +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphQLClient } from "graphql-request";
|
|
2
|
+
export declare const operatorRoleHeaders: {
|
|
3
|
+
readonly "x-hasura-role": "operator";
|
|
4
|
+
};
|
|
5
|
+
export declare const marketerGQLPath = "/v1/graphql";
|
|
6
|
+
export declare function marketerGraphQLClient(baseUrl: URL): GraphQLClient;
|
|
7
|
+
export declare const mantaGQLPath = "/graphql";
|
|
8
|
+
export declare function mantaGraphQLClient(baseUrl: URL, onUnauthorized?: () => void, headers?: Record<string, string>): GraphQLClient;
|
|
9
|
+
//# sourceMappingURL=graphql-clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-clients.d.ts","sourceRoot":"","sources":["../src/graphql-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAI7D,eAAO,MAAM,mBAAmB;;CAA2C,CAAC;AAE5E,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAG7C,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,GAAG,iBAKjD;AAED,eAAO,MAAM,YAAY,aAAa,CAAC;AAGvC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,EAAE,MAAM,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,iBAa7G"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ClientError, GraphQLClient } from "graphql-request";
|
|
2
|
+
// These are default client constructors for the Marketer and Manta GraphQL APIs
|
|
3
|
+
export const operatorRoleHeaders = { "x-hasura-role": "operator" };
|
|
4
|
+
export const marketerGQLPath = "/v1/graphql";
|
|
5
|
+
// To use custom keycloak headers, use headers: { "X-Keycloak-Token": keycloakToken } instead of credentials
|
|
6
|
+
export function marketerGraphQLClient(baseUrl) {
|
|
7
|
+
const url = new URL(marketerGQLPath, baseUrl);
|
|
8
|
+
return new GraphQLClient(url.toString(), {
|
|
9
|
+
credentials: "include",
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export const mantaGQLPath = "/graphql";
|
|
13
|
+
// To use custom keycloak headers, use headers: { "Authorization": `Bearer ${keycloakToken}` } instead of credentials
|
|
14
|
+
export function mantaGraphQLClient(baseUrl, onUnauthorized, headers) {
|
|
15
|
+
const url = new URL(mantaGQLPath, baseUrl);
|
|
16
|
+
return new GraphQLClient(url.toString(), {
|
|
17
|
+
credentials: "include",
|
|
18
|
+
headers,
|
|
19
|
+
responseMiddleware: onUnauthorized
|
|
20
|
+
? (response) => {
|
|
21
|
+
if (response instanceof ClientError && response.response.status === 401) {
|
|
22
|
+
onUnauthorized();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
: undefined,
|
|
26
|
+
});
|
|
27
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-plan.d.ts","sourceRoot":"","sources":["../../src/shared/action-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isActionPlanGraphIri } from "@manta-eu/rdf-lib/namespaces";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function humanizeEntityName(raw: string): string;
|
|
2
|
+
export declare function humanizePlanName(raw: string): string;
|
|
3
|
+
export declare function extractPlanName(iri: string): string;
|
|
4
|
+
export declare function buildPlanIri(planName: string): string;
|
|
5
|
+
export declare function planGraphIriToFragment(iri: string): string;
|
|
6
|
+
export declare function buildPlanHref(iri: string): string;
|
|
7
|
+
export declare function buildActivityIri(param: string): string;
|
|
8
|
+
export declare function buildActivityHref(iri: string): string;
|
|
9
|
+
//# sourceMappingURL=agent-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-mode.d.ts","sourceRoot":"","sources":["../../src/shared/agent-mode.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,UAEjD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,UAExC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,UAE5C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { baseIri, iriLocalName } from "./rdf-namespaces.js";
|
|
2
|
+
import { splitIdentifierWords } from "@manta-eu/lib/identifier-words";
|
|
3
|
+
export function humanizeEntityName(raw) {
|
|
4
|
+
return splitIdentifierWords(raw);
|
|
5
|
+
}
|
|
6
|
+
export function humanizePlanName(raw) {
|
|
7
|
+
return humanizeEntityName(raw.replace(/^ActionPlan_/, ""));
|
|
8
|
+
}
|
|
9
|
+
export function extractPlanName(iri) {
|
|
10
|
+
const lastSlash = iri.lastIndexOf("/");
|
|
11
|
+
const lastHash = iri.lastIndexOf("#");
|
|
12
|
+
const lastSeparator = Math.max(lastSlash, lastHash);
|
|
13
|
+
if (lastSeparator > 0) {
|
|
14
|
+
return humanizePlanName(iri.slice(lastSeparator + 1));
|
|
15
|
+
}
|
|
16
|
+
return iri;
|
|
17
|
+
}
|
|
18
|
+
export function buildPlanIri(planName) {
|
|
19
|
+
if (planName.startsWith("http://") || planName.startsWith("https://")) {
|
|
20
|
+
return planName;
|
|
21
|
+
}
|
|
22
|
+
return `${baseIri}${planName}`;
|
|
23
|
+
}
|
|
24
|
+
export function planGraphIriToFragment(iri) {
|
|
25
|
+
return iriLocalName(iri) || "";
|
|
26
|
+
}
|
|
27
|
+
export function buildPlanHref(iri) {
|
|
28
|
+
return `/plans/${encodeURIComponent(planGraphIriToFragment(iri))}`;
|
|
29
|
+
}
|
|
30
|
+
export function buildActivityIri(param) {
|
|
31
|
+
if (param.startsWith("http://") || param.startsWith("https://")) {
|
|
32
|
+
return param;
|
|
33
|
+
}
|
|
34
|
+
return `${baseIri}${param}`;
|
|
35
|
+
}
|
|
36
|
+
export function buildActivityHref(iri) {
|
|
37
|
+
return `/activity/${encodeURIComponent(iriLocalName(iri) || iri)}`;
|
|
38
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ChatUIMessage } from "./index.js";
|
|
2
|
+
import type { IRI } from "./rdf-namespaces.js";
|
|
3
|
+
export declare enum ChatContextKind {
|
|
4
|
+
RuleEdit = "RULE_EDIT",
|
|
5
|
+
RuleCreate = "RULE_CREATE",
|
|
6
|
+
Plan = "PLAN"
|
|
7
|
+
}
|
|
8
|
+
export type ChatContext = {
|
|
9
|
+
kind: ChatContextKind.RuleEdit;
|
|
10
|
+
ruleIri: IRI;
|
|
11
|
+
} | {
|
|
12
|
+
kind: ChatContextKind.RuleCreate;
|
|
13
|
+
draftIri: IRI;
|
|
14
|
+
} | {
|
|
15
|
+
kind: ChatContextKind.Plan;
|
|
16
|
+
planGraphIri: IRI;
|
|
17
|
+
};
|
|
18
|
+
export declare function isDraftChatContext(context: ChatContext | undefined): boolean;
|
|
19
|
+
export declare function isRuleScopedChatContext(context: ChatContext | undefined): boolean;
|
|
20
|
+
export type CachedMemorySchemaProperty = {
|
|
21
|
+
path: string;
|
|
22
|
+
label: string;
|
|
23
|
+
dataType: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
allowedValues: string[];
|
|
26
|
+
keyProperty: boolean;
|
|
27
|
+
inferred: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type CachedMemorySchema = {
|
|
30
|
+
iri: string;
|
|
31
|
+
label: string;
|
|
32
|
+
description: string | null;
|
|
33
|
+
properties: CachedMemorySchemaProperty[];
|
|
34
|
+
};
|
|
35
|
+
export type ChatState = {
|
|
36
|
+
chatIRI: IRI;
|
|
37
|
+
context?: ChatContext;
|
|
38
|
+
contextTokens: number;
|
|
39
|
+
};
|
|
40
|
+
export type SendAgentMessage = (message: ChatUIMessage) => Promise<void>;
|
|
41
|
+
//# sourceMappingURL=agent-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-types.d.ts","sourceRoot":"","sources":["../../src/shared/agent-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE5C,oBAAY,eAAe;IACzB,QAAQ,cAAc;IACtB,UAAU,gBAAgB;IAC1B,IAAI,SAAS;CACd;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,eAAe,CAAC,UAAU,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;IAAC,YAAY,EAAE,GAAG,CAAA;CAAE,CAAC;AAEtD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAE5E;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAEjF;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,0BAA0B,EAAE,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var ChatContextKind;
|
|
2
|
+
(function (ChatContextKind) {
|
|
3
|
+
ChatContextKind["RuleEdit"] = "RULE_EDIT";
|
|
4
|
+
ChatContextKind["RuleCreate"] = "RULE_CREATE";
|
|
5
|
+
ChatContextKind["Plan"] = "PLAN";
|
|
6
|
+
})(ChatContextKind || (ChatContextKind = {}));
|
|
7
|
+
export function isDraftChatContext(context) {
|
|
8
|
+
return context?.kind === ChatContextKind.RuleCreate;
|
|
9
|
+
}
|
|
10
|
+
export function isRuleScopedChatContext(context) {
|
|
11
|
+
return context?.kind === ChatContextKind.RuleEdit || context?.kind === ChatContextKind.RuleCreate;
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ChatContext } from "./agent-types.js";
|
|
2
|
+
import { type IRI } from "./rdf-namespaces.js";
|
|
3
|
+
export declare function generateRuleDraftIri(): IRI;
|
|
4
|
+
export declare function contextChatName(context: ChatContext): string;
|
|
5
|
+
export declare function chatContextIri(context: ChatContext): IRI;
|
|
6
|
+
export declare function parseStoredChatContext(input: unknown): ChatContext;
|
|
7
|
+
//# sourceMappingURL=chat-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-context.d.ts","sourceRoot":"","sources":["../../src/shared/chat-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAA8B,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAaxE,wBAAgB,oBAAoB,IAAI,GAAG,CAE1C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAS5D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,GAAG,CAMxD;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAQlE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { extractPlanName, humanizeEntityName } from "./agent-mode.js";
|
|
2
|
+
import { ChatContextKind } from "./agent-types.js";
|
|
3
|
+
import { expandPrefix, iriLocalName } from "./rdf-namespaces.js";
|
|
4
|
+
import { match } from "ts-pattern";
|
|
5
|
+
import { v7 as uuidv7 } from "uuid";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
const storedChatContextSchema = z.object({
|
|
8
|
+
kind: z.enum(ChatContextKind),
|
|
9
|
+
iri: z
|
|
10
|
+
.string()
|
|
11
|
+
.min(1)
|
|
12
|
+
.transform((iri) => iri),
|
|
13
|
+
});
|
|
14
|
+
export function generateRuleDraftIri() {
|
|
15
|
+
return expandPrefix(`:RuleDraft_${uuidv7()}`);
|
|
16
|
+
}
|
|
17
|
+
export function contextChatName(context) {
|
|
18
|
+
return match(context)
|
|
19
|
+
.with({ kind: ChatContextKind.RuleEdit }, ({ ruleIri }) => `Edit rule: ${humanizeEntityName(iriLocalName(ruleIri).replace(/^Rule_/, ""))}`)
|
|
20
|
+
.with({ kind: ChatContextKind.RuleCreate }, () => "Create rule")
|
|
21
|
+
.with({ kind: ChatContextKind.Plan }, ({ planGraphIri }) => extractPlanName(planGraphIri))
|
|
22
|
+
.exhaustive();
|
|
23
|
+
}
|
|
24
|
+
export function chatContextIri(context) {
|
|
25
|
+
return match(context)
|
|
26
|
+
.with({ kind: ChatContextKind.RuleEdit }, (c) => c.ruleIri)
|
|
27
|
+
.with({ kind: ChatContextKind.RuleCreate }, (c) => c.draftIri)
|
|
28
|
+
.with({ kind: ChatContextKind.Plan }, (c) => c.planGraphIri)
|
|
29
|
+
.exhaustive();
|
|
30
|
+
}
|
|
31
|
+
export function parseStoredChatContext(input) {
|
|
32
|
+
const { kind, iri } = storedChatContextSchema.parse(input);
|
|
33
|
+
return match(kind)
|
|
34
|
+
.with(ChatContextKind.RuleEdit, () => ({ kind: ChatContextKind.RuleEdit, ruleIri: iri }))
|
|
35
|
+
.with(ChatContextKind.RuleCreate, () => ({ kind: ChatContextKind.RuleCreate, draftIri: iri }))
|
|
36
|
+
.with(ChatContextKind.Plan, () => ({ kind: ChatContextKind.Plan, planGraphIri: iri }))
|
|
37
|
+
.exhaustive();
|
|
38
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { ChatContextKind } from "./agent-types.js";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
export declare const chatManagerBasePath = "agents/chat-manager";
|
|
4
|
+
export declare const thinkChatFacetPath = "think-chat";
|
|
5
|
+
export declare const defaultConversationName = "New chat";
|
|
6
|
+
export declare const chatManagerScopeSchema: z.ZodObject<{
|
|
7
|
+
version: z.ZodLiteral<1>;
|
|
8
|
+
realm: z.ZodString;
|
|
9
|
+
datastoreId: z.ZodString;
|
|
10
|
+
userId: z.ZodString;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export type ChatManagerScope = z.infer<typeof chatManagerScopeSchema>;
|
|
13
|
+
export declare const chatIdSchema: z.ZodUUID;
|
|
14
|
+
export declare const chatContextSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
15
|
+
kind: z.ZodLiteral<ChatContextKind.RuleEdit>;
|
|
16
|
+
ruleIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
17
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
18
|
+
kind: z.ZodLiteral<ChatContextKind.RuleCreate>;
|
|
19
|
+
draftIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
20
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
21
|
+
kind: z.ZodLiteral<ChatContextKind.Plan>;
|
|
22
|
+
planGraphIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
23
|
+
}, z.core.$strict>], "kind">;
|
|
24
|
+
export declare const chatManagerStateSchema: z.ZodObject<{
|
|
25
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
26
|
+
scope: z.ZodNullable<z.ZodObject<{
|
|
27
|
+
version: z.ZodLiteral<1>;
|
|
28
|
+
realm: z.ZodString;
|
|
29
|
+
datastoreId: z.ZodString;
|
|
30
|
+
userId: z.ZodString;
|
|
31
|
+
}, z.core.$strict>>;
|
|
32
|
+
chatListRevision: z.ZodNumber;
|
|
33
|
+
lastRetentionCheckAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
|
|
34
|
+
}, z.core.$strict>;
|
|
35
|
+
export type ChatManagerState = z.infer<typeof chatManagerStateSchema>;
|
|
36
|
+
export declare const conversationLifecycleStatusSchema: z.ZodEnum<{
|
|
37
|
+
creating: "creating";
|
|
38
|
+
active: "active";
|
|
39
|
+
deleting: "deleting";
|
|
40
|
+
}>;
|
|
41
|
+
export type ConversationLifecycleStatus = z.infer<typeof conversationLifecycleStatusSchema>;
|
|
42
|
+
export declare const conversationSummarySchema: z.ZodObject<{
|
|
43
|
+
id: z.ZodUUID;
|
|
44
|
+
chatIRI: z.ZodString;
|
|
45
|
+
title: z.ZodString;
|
|
46
|
+
context: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
47
|
+
kind: z.ZodLiteral<ChatContextKind.RuleEdit>;
|
|
48
|
+
ruleIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
kind: z.ZodLiteral<ChatContextKind.RuleCreate>;
|
|
51
|
+
draftIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
52
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
53
|
+
kind: z.ZodLiteral<ChatContextKind.Plan>;
|
|
54
|
+
planGraphIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
55
|
+
}, z.core.$strict>], "kind">>;
|
|
56
|
+
createdAt: z.ZodISODateTime;
|
|
57
|
+
updatedAt: z.ZodISODateTime;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
export type ConversationSummary = z.infer<typeof conversationSummarySchema>;
|
|
60
|
+
export declare const createConversationInputSchema: z.ZodObject<{
|
|
61
|
+
name: z.ZodOptional<z.ZodString>;
|
|
62
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
export type CreateConversationInput = z.input<typeof createConversationInputSchema>;
|
|
65
|
+
export declare const contextConversationInputSchema: z.ZodObject<{
|
|
66
|
+
context: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
67
|
+
kind: z.ZodLiteral<ChatContextKind.RuleEdit>;
|
|
68
|
+
ruleIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
69
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
70
|
+
kind: z.ZodLiteral<ChatContextKind.RuleCreate>;
|
|
71
|
+
draftIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
72
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
73
|
+
kind: z.ZodLiteral<ChatContextKind.Plan>;
|
|
74
|
+
planGraphIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
75
|
+
}, z.core.$strict>], "kind">;
|
|
76
|
+
}, z.core.$strict>;
|
|
77
|
+
export type ContextConversationInput = z.input<typeof contextConversationInputSchema>;
|
|
78
|
+
export declare const reassignConversationContextInputSchema: z.ZodObject<{
|
|
79
|
+
context: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
80
|
+
kind: z.ZodLiteral<ChatContextKind.RuleEdit>;
|
|
81
|
+
ruleIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
82
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
83
|
+
kind: z.ZodLiteral<ChatContextKind.RuleCreate>;
|
|
84
|
+
draftIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
85
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
86
|
+
kind: z.ZodLiteral<ChatContextKind.Plan>;
|
|
87
|
+
planGraphIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
88
|
+
}, z.core.$strict>], "kind">;
|
|
89
|
+
conversationId: z.ZodUUID;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
export type ReassignConversationContextInput = z.input<typeof reassignConversationContextInputSchema>;
|
|
92
|
+
export declare const conversationIdInputSchema: z.ZodObject<{
|
|
93
|
+
id: z.ZodUUID;
|
|
94
|
+
}, z.core.$strict>;
|
|
95
|
+
export type ConversationIdInput = z.input<typeof conversationIdInputSchema>;
|
|
96
|
+
export declare const renameConversationInputSchema: z.ZodObject<{
|
|
97
|
+
id: z.ZodUUID;
|
|
98
|
+
title: z.ZodString;
|
|
99
|
+
}, z.core.$strict>;
|
|
100
|
+
export type RenameConversationInput = z.input<typeof renameConversationInputSchema>;
|
|
101
|
+
export declare const listConversationsInputSchema: z.ZodObject<{
|
|
102
|
+
search: z.ZodOptional<z.ZodString>;
|
|
103
|
+
orderBy: z.ZodDefault<z.ZodEnum<{
|
|
104
|
+
CREATED_AT: "CREATED_AT";
|
|
105
|
+
UPDATED_AT: "UPDATED_AT";
|
|
106
|
+
}>>;
|
|
107
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
108
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
export type ListConversationsInput = z.input<typeof listConversationsInputSchema>;
|
|
111
|
+
export declare const deleteConversationResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
112
|
+
status: z.ZodLiteral<"deleted">;
|
|
113
|
+
id: z.ZodUUID;
|
|
114
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
115
|
+
status: z.ZodLiteral<"not_found">;
|
|
116
|
+
}, z.core.$strict>], "status">;
|
|
117
|
+
export type DeleteConversationResult = z.infer<typeof deleteConversationResultSchema>;
|
|
118
|
+
export declare const conversationConfigSchema: z.ZodObject<{
|
|
119
|
+
version: z.ZodLiteral<1>;
|
|
120
|
+
scope: z.ZodObject<{
|
|
121
|
+
version: z.ZodLiteral<1>;
|
|
122
|
+
realm: z.ZodString;
|
|
123
|
+
datastoreId: z.ZodString;
|
|
124
|
+
userId: z.ZodString;
|
|
125
|
+
}, z.core.$strict>;
|
|
126
|
+
chatId: z.ZodUUID;
|
|
127
|
+
chatIRI: z.ZodString;
|
|
128
|
+
context: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
129
|
+
kind: z.ZodLiteral<ChatContextKind.RuleEdit>;
|
|
130
|
+
ruleIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
131
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
132
|
+
kind: z.ZodLiteral<ChatContextKind.RuleCreate>;
|
|
133
|
+
draftIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
134
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
135
|
+
kind: z.ZodLiteral<ChatContextKind.Plan>;
|
|
136
|
+
planGraphIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
137
|
+
}, z.core.$strict>], "kind">>;
|
|
138
|
+
}, z.core.$strict>;
|
|
139
|
+
export type ConversationConfig = z.infer<typeof conversationConfigSchema>;
|
|
140
|
+
export declare const thinkChatStateSchema: z.ZodObject<{
|
|
141
|
+
config: z.ZodNullable<z.ZodObject<{
|
|
142
|
+
version: z.ZodLiteral<1>;
|
|
143
|
+
scope: z.ZodObject<{
|
|
144
|
+
version: z.ZodLiteral<1>;
|
|
145
|
+
realm: z.ZodString;
|
|
146
|
+
datastoreId: z.ZodString;
|
|
147
|
+
userId: z.ZodString;
|
|
148
|
+
}, z.core.$strict>;
|
|
149
|
+
chatId: z.ZodUUID;
|
|
150
|
+
chatIRI: z.ZodString;
|
|
151
|
+
context: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
152
|
+
kind: z.ZodLiteral<ChatContextKind.RuleEdit>;
|
|
153
|
+
ruleIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
154
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
155
|
+
kind: z.ZodLiteral<ChatContextKind.RuleCreate>;
|
|
156
|
+
draftIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
157
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
158
|
+
kind: z.ZodLiteral<ChatContextKind.Plan>;
|
|
159
|
+
planGraphIri: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
160
|
+
}, z.core.$strict>], "kind">>;
|
|
161
|
+
}, z.core.$strict>>;
|
|
162
|
+
contextTokens: z.ZodNumber;
|
|
163
|
+
compacting: z.ZodDefault<z.ZodBoolean>;
|
|
164
|
+
automaticTitleGenerationComplete: z.ZodDefault<z.ZodBoolean>;
|
|
165
|
+
}, z.core.$strict>;
|
|
166
|
+
export type ThinkChatState = z.infer<typeof thinkChatStateSchema>;
|
|
167
|
+
/**
|
|
168
|
+
* Browser-safe surface for the owner Agent. Keeping this contract separate
|
|
169
|
+
* from the Worker class prevents server-only types and internal RPC methods
|
|
170
|
+
* from entering the client bundle.
|
|
171
|
+
*/
|
|
172
|
+
export type ChatManagerClient = {
|
|
173
|
+
readonly state: ChatManagerState;
|
|
174
|
+
createConversation(input?: CreateConversationInput): Promise<ConversationSummary>;
|
|
175
|
+
findContextConversation(input: ContextConversationInput): Promise<ConversationSummary | null>;
|
|
176
|
+
ensureContextConversation(input: ContextConversationInput): Promise<ConversationSummary>;
|
|
177
|
+
reassignConversationContext(input: ReassignConversationContextInput): Promise<ConversationSummary>;
|
|
178
|
+
getConversation(input: ConversationIdInput): Promise<ConversationSummary | null>;
|
|
179
|
+
listConversations(input?: ListConversationsInput): Promise<ConversationSummary[]>;
|
|
180
|
+
renameConversation(input: RenameConversationInput): Promise<ConversationSummary | null>;
|
|
181
|
+
deleteConversation(input: ConversationIdInput): Promise<DeleteConversationResult>;
|
|
182
|
+
};
|
|
183
|
+
//# sourceMappingURL=chat-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-manager.d.ts","sourceRoot":"","sources":["../../src/shared/chat-manager.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ChatContextKind } from "./agent-types.js";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
export const chatManagerBasePath = "agents/chat-manager";
|
|
4
|
+
export const thinkChatFacetPath = "think-chat";
|
|
5
|
+
export const defaultConversationName = "New chat";
|
|
6
|
+
export const chatManagerScopeSchema = z.strictObject({
|
|
7
|
+
version: z.literal(1),
|
|
8
|
+
realm: z.string().min(1),
|
|
9
|
+
datastoreId: z.string().min(1),
|
|
10
|
+
userId: z.string().min(1),
|
|
11
|
+
});
|
|
12
|
+
export const chatIdSchema = z.uuid();
|
|
13
|
+
const iriSchema = z
|
|
14
|
+
.string()
|
|
15
|
+
.min(1)
|
|
16
|
+
.transform((iri) => iri);
|
|
17
|
+
export const chatContextSchema = z.discriminatedUnion("kind", [
|
|
18
|
+
z.strictObject({ kind: z.literal(ChatContextKind.RuleEdit), ruleIri: iriSchema }),
|
|
19
|
+
z.strictObject({ kind: z.literal(ChatContextKind.RuleCreate), draftIri: iriSchema }),
|
|
20
|
+
z.strictObject({ kind: z.literal(ChatContextKind.Plan), planGraphIri: iriSchema }),
|
|
21
|
+
]);
|
|
22
|
+
export const chatManagerStateSchema = z.strictObject({
|
|
23
|
+
schemaVersion: z.literal(1),
|
|
24
|
+
scope: chatManagerScopeSchema.nullable(),
|
|
25
|
+
chatListRevision: z.number().int().nonnegative(),
|
|
26
|
+
lastRetentionCheckAt: z.iso.datetime().nullable().default(null),
|
|
27
|
+
});
|
|
28
|
+
export const conversationLifecycleStatusSchema = z.enum(["creating", "active", "deleting"]);
|
|
29
|
+
export const conversationSummarySchema = z.strictObject({
|
|
30
|
+
id: chatIdSchema,
|
|
31
|
+
chatIRI: z.string().min(1),
|
|
32
|
+
title: z.string().min(1),
|
|
33
|
+
context: chatContextSchema.nullable(),
|
|
34
|
+
createdAt: z.iso.datetime(),
|
|
35
|
+
updatedAt: z.iso.datetime(),
|
|
36
|
+
});
|
|
37
|
+
export const createConversationInputSchema = z.strictObject({
|
|
38
|
+
name: z.string().trim().min(1).max(200).optional(),
|
|
39
|
+
idempotencyKey: z.string().trim().min(1).max(200).optional(),
|
|
40
|
+
});
|
|
41
|
+
export const contextConversationInputSchema = z.strictObject({
|
|
42
|
+
context: chatContextSchema,
|
|
43
|
+
});
|
|
44
|
+
export const reassignConversationContextInputSchema = z.strictObject({
|
|
45
|
+
context: chatContextSchema,
|
|
46
|
+
conversationId: chatIdSchema,
|
|
47
|
+
});
|
|
48
|
+
export const conversationIdInputSchema = z.strictObject({ id: chatIdSchema });
|
|
49
|
+
export const renameConversationInputSchema = z.strictObject({
|
|
50
|
+
id: chatIdSchema,
|
|
51
|
+
title: z.string().trim().min(1).max(200),
|
|
52
|
+
});
|
|
53
|
+
export const listConversationsInputSchema = z.strictObject({
|
|
54
|
+
search: z.string().trim().max(200).optional(),
|
|
55
|
+
orderBy: z.enum(["CREATED_AT", "UPDATED_AT"]).default("UPDATED_AT"),
|
|
56
|
+
limit: z.number().int().min(1).max(100).default(10),
|
|
57
|
+
offset: z.number().int().min(0).default(0),
|
|
58
|
+
});
|
|
59
|
+
export const deleteConversationResultSchema = z.discriminatedUnion("status", [
|
|
60
|
+
z.strictObject({ status: z.literal("deleted"), id: chatIdSchema }),
|
|
61
|
+
z.strictObject({ status: z.literal("not_found") }),
|
|
62
|
+
]);
|
|
63
|
+
export const conversationConfigSchema = z.strictObject({
|
|
64
|
+
version: z.literal(1),
|
|
65
|
+
scope: chatManagerScopeSchema,
|
|
66
|
+
chatId: chatIdSchema,
|
|
67
|
+
chatIRI: z.string().min(1),
|
|
68
|
+
context: chatContextSchema.nullable(),
|
|
69
|
+
});
|
|
70
|
+
export const thinkChatStateSchema = z.strictObject({
|
|
71
|
+
config: conversationConfigSchema.nullable(),
|
|
72
|
+
contextTokens: z.number().int().nonnegative(),
|
|
73
|
+
compacting: z.boolean().default(false),
|
|
74
|
+
automaticTitleGenerationComplete: z.boolean().default(false),
|
|
75
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export declare const chatTurnErrorMessages: {
|
|
3
|
+
readonly conversationScope: "This chat can't be used with the currently selected datastore.";
|
|
4
|
+
readonly contextOverflow: "This chat has become too long to continue.";
|
|
5
|
+
readonly messageNotSaved: "Manta couldn't complete this response, and your message may not have been saved. Please send it again.";
|
|
6
|
+
readonly unexpected: "Manta couldn't complete this response. Please try again.";
|
|
7
|
+
};
|
|
8
|
+
export declare const chatTurnErrorMessageSchema: z.ZodEnum<{
|
|
9
|
+
"This chat can't be used with the currently selected datastore.": "This chat can't be used with the currently selected datastore.";
|
|
10
|
+
"This chat has become too long to continue.": "This chat has become too long to continue.";
|
|
11
|
+
"Manta couldn't complete this response, and your message may not have been saved. Please send it again.": "Manta couldn't complete this response, and your message may not have been saved. Please send it again.";
|
|
12
|
+
"Manta couldn't complete this response. Please try again.": "Manta couldn't complete this response. Please try again.";
|
|
13
|
+
}>;
|
|
14
|
+
export type ChatTurnErrorMessage = z.infer<typeof chatTurnErrorMessageSchema>;
|
|
15
|
+
export declare function resolveChatTurnErrorMessage(error: unknown): ChatTurnErrorMessage;
|
|
16
|
+
//# sourceMappingURL=chat-turn-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-turn-errors.d.ts","sourceRoot":"","sources":["../../src/shared/chat-turn-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,eAAO,MAAM,qBAAqB;;;;;CAMxB,CAAC;AAEX,eAAO,MAAM,0BAA0B;;;;;EAKrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAKhF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export const chatTurnErrorMessages = {
|
|
3
|
+
conversationScope: "This chat can't be used with the currently selected datastore.",
|
|
4
|
+
contextOverflow: "This chat has become too long to continue.",
|
|
5
|
+
messageNotSaved: "Manta couldn't complete this response, and your message may not have been saved. Please send it again.",
|
|
6
|
+
unexpected: "Manta couldn't complete this response. Please try again.",
|
|
7
|
+
};
|
|
8
|
+
export const chatTurnErrorMessageSchema = z.enum([
|
|
9
|
+
chatTurnErrorMessages.conversationScope,
|
|
10
|
+
chatTurnErrorMessages.contextOverflow,
|
|
11
|
+
chatTurnErrorMessages.messageNotSaved,
|
|
12
|
+
chatTurnErrorMessages.unexpected,
|
|
13
|
+
]);
|
|
14
|
+
export function resolveChatTurnErrorMessage(error) {
|
|
15
|
+
const message = error instanceof Error ? error.message : error;
|
|
16
|
+
const parsed = chatTurnErrorMessageSchema.safeParse(message);
|
|
17
|
+
return parsed.success ? parsed.data : chatTurnErrorMessages.unexpected;
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { KeycloakRealm } from "@manta-eu/ldo/realm";
|
|
2
|
+
export declare const selectedDatastoreCookieName = "selected-datastore";
|
|
3
|
+
export declare const errorRoutePath = "/error";
|
|
4
|
+
export declare const scheduleToolingFlagKey = "schedule-tooling-enabled";
|
|
5
|
+
export declare const teamActivationFlagKey = "team-activation-enabled";
|
|
6
|
+
export declare const memoryExtractionFlagKey = "memory-extraction-enabled";
|
|
7
|
+
export declare const memoryAutoSupersedeFlagKey = "memory-auto-supersede-enabled";
|
|
8
|
+
export declare const memoryReplayFlagKey = "memory-replay-enabled";
|
|
9
|
+
export declare const memoryMaintenanceFlagKey = "memory-maintenance-enabled";
|
|
10
|
+
export declare const enableDatastoreRemoval = false;
|
|
11
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/shared/constants.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAEhE,eAAO,MAAM,cAAc,WAAW,CAAC;AAEvC,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AACjE,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAC/D,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AACnE,eAAO,MAAM,0BAA0B,kCAAkC,CAAC;AAC1E,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAC3D,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AAGrE,eAAO,MAAM,sBAAsB,QAAQ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const selectedDatastoreCookieName = "selected-datastore";
|
|
2
|
+
export const errorRoutePath = "/error";
|
|
3
|
+
export const scheduleToolingFlagKey = "schedule-tooling-enabled";
|
|
4
|
+
export const teamActivationFlagKey = "team-activation-enabled";
|
|
5
|
+
export const memoryExtractionFlagKey = "memory-extraction-enabled";
|
|
6
|
+
export const memoryAutoSupersedeFlagKey = "memory-auto-supersede-enabled";
|
|
7
|
+
export const memoryReplayFlagKey = "memory-replay-enabled";
|
|
8
|
+
export const memoryMaintenanceFlagKey = "memory-maintenance-enabled";
|
|
9
|
+
// Gates "Remove"/"Restore" and "Show archived". Off: see wiki/infisical-secrets.md § Removal gap.
|
|
10
|
+
export const enableDatastoreRemoval = false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-starter-defaults.d.ts","sourceRoot":"","sources":["../../src/shared/conversation-starter-defaults.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,0BAA0B,GAAG;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,0BAA0B,EAmBnE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const defaultConversationStarters = [
|
|
2
|
+
{
|
|
3
|
+
id: "default-top-advertising-strategies",
|
|
4
|
+
title: "What were the top advertising strategies for Meta in 2025?",
|
|
5
|
+
description: "Explore the most effective Meta advertising tactics and trends from 2025.",
|
|
6
|
+
priority: 1,
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: "default-common-causes-of-ad-spend-waste",
|
|
10
|
+
title: "What are the 3 most common causes of ad spend waste?",
|
|
11
|
+
description: "Discover the biggest budget drains and how to avoid them.",
|
|
12
|
+
priority: 2,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "default-top-benefits-of-advertising-on-snapchat",
|
|
16
|
+
title: "Top benefits of advertising on Snapchat?",
|
|
17
|
+
description: "Learn why Snapchat could be a valuable addition to your ad mix.",
|
|
18
|
+
priority: 3,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datastore-id.d.ts","sourceRoot":"","sources":["../../src/shared/datastore-id.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5C;AAGD,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAEtF;AAKD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEtD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isPresent } from "@manta-eu/lib/present";
|
|
2
|
+
export function slugify(name) {
|
|
3
|
+
return name
|
|
4
|
+
.trim()
|
|
5
|
+
.toLowerCase()
|
|
6
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
7
|
+
.replace(/^-+|-+$/g, "");
|
|
8
|
+
}
|
|
9
|
+
// Org slug + full group path: "Demo Portfolio Co" + ["Vertical A","Team 1"] -> "demo-portfolio-co-vertical-a-team-1".
|
|
10
|
+
export function deriveDatastoreId(organizationName, segments) {
|
|
11
|
+
return [organizationName, ...segments].map(slugify).filter(isPresent).join("-");
|
|
12
|
+
}
|
|
13
|
+
// Validated before reaching Infisical/KGC/RDFox since the Keycloak attribute is admin-settable.
|
|
14
|
+
const datastoreIdPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
15
|
+
export function isValidDatastoreId(id) {
|
|
16
|
+
return datastoreIdPattern.test(id);
|
|
17
|
+
}
|