@antelopejs/dms-assistant 0.2.8-next.450.g08ef749 → 0.2.8-next.452.gae7538c
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/pages/settings/availability.js +1 -16
- package/dist/pages/settings/availability.js.map +1 -1
- package/dist/pages/settings/options.d.ts +0 -2
- package/dist/pages/settings/options.js +3 -30
- package/dist/pages/settings/options.js.map +1 -1
- package/dist/pages/settings/page.d.ts +1 -0
- package/dist/pages/settings/page.js +2 -0
- package/dist/pages/settings/page.js.map +1 -1
- package/dist/pages/settings/sections.js +2 -74
- package/dist/pages/settings/sections.js.map +1 -1
- package/dist/routes/settings.d.ts +1 -1
- package/dist/routes/settings.js +22 -3
- package/dist/routes/settings.js.map +1 -1
- package/frontend-vue/app/components/GuardRails.vue +148 -0
- package/frontend-vue/app/plugins/ai.client.ts +8 -2
- package/frontend-vue/app/runtime/assistant-session.ts +4 -1
- package/frontend-vue/app/runtime/host-commands.ts +82 -47
- package/frontend-vue/app/views/composables/useGuardRails.ts +106 -0
- package/frontend-vue/app/views/constants.ts +1 -0
- package/frontend-vue/app/views/guard-rails.ts +113 -0
- package/frontend-vue/app/views/types.ts +2 -0
- package/frontend-vue/i18n/locales/dms-assistant-pages-en-GB.json +5 -1
- package/frontend-vue/i18n/locales/dms-assistant-pages-fr-FR.json +5 -1
- package/frontend-vue/i18n/locales/dms-assistant-views-en-GB.json +5 -0
- package/frontend-vue/i18n/locales/dms-assistant-views-fr-FR.json +5 -0
- package/package.json +2 -2
- package/sidecar/dist/constants/timing.d.ts +1 -1
- package/sidecar/dist/constants/timing.js +1 -1
- package/sidecar/dist/constants/timing.js.map +1 -1
|
@@ -24,7 +24,6 @@ const CAPABILITIES_ANSWER = zod_1.z.looseObject({
|
|
|
24
24
|
})
|
|
25
25
|
.optional())
|
|
26
26
|
.optional(),
|
|
27
|
-
builderAvailable: zod_1.z.boolean().optional(),
|
|
28
27
|
defaults: zod_1.z.record(zod_1.z.string(), JSON_ANSWER).optional(),
|
|
29
28
|
});
|
|
30
29
|
const OPTIONS_WITH_ITEMS = zod_1.z.looseObject({
|
|
@@ -57,16 +56,6 @@ function locksFor(capabilities) {
|
|
|
57
56
|
}
|
|
58
57
|
return locks;
|
|
59
58
|
}
|
|
60
|
-
const SAFE_MODE_FIELD = "safeMode";
|
|
61
|
-
function lockSafeMode(entry) {
|
|
62
|
-
if (!("component" in entry) || entry.id !== SAFE_MODE_FIELD)
|
|
63
|
-
return entry;
|
|
64
|
-
return {
|
|
65
|
-
...entry,
|
|
66
|
-
disabled: true,
|
|
67
|
-
description: (0, options_1.settingsText)("safe_mode", "builder_missing"),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
59
|
const DEFAULT_VALUE = zod_1.z.lazy(() => zod_1.z.union([
|
|
71
60
|
zod_1.z.string(),
|
|
72
61
|
zod_1.z.number(),
|
|
@@ -100,11 +89,7 @@ async function applySidecarSettings(_permissions, options) {
|
|
|
100
89
|
const capabilities = await (0, sidecar_1.readSidecar)(SETTINGS_PATH, CAPABILITIES_ANSWER, {});
|
|
101
90
|
const defaults = (0, settings_values_1.asFormValues)(capabilities.defaults ?? {});
|
|
102
91
|
const locks = locksFor(capabilities);
|
|
103
|
-
const
|
|
104
|
-
const fields = options.fields.map((entry) => {
|
|
105
|
-
const locked = locks.reduce((current, lock) => lockField(current, lock), withDefaults(entry, defaults));
|
|
106
|
-
return isBuilderMissing ? lockSafeMode(locked) : locked;
|
|
107
|
-
});
|
|
92
|
+
const fields = options.fields.map((entry) => locks.reduce((current, lock) => lockField(current, lock), withDefaults(entry, defaults)));
|
|
108
93
|
return { ...options, fields };
|
|
109
94
|
}
|
|
110
95
|
//# sourceMappingURL=availability.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"availability.js","sourceRoot":"","sources":["../../../src/pages/settings/availability.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"availability.js","sourceRoot":"","sources":["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E,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACxE,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AACjE,CAAC;AAQM,KAAK,UAAU,oBAAoB,CACxC,YAAyB,EACzB,OAA4B;IAE5B,IAAI,MAAM,IAAA,iCAAiB,GAAE;QAAE,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,MAAM,IAAA,qBAAW,EACpC,aAAa,EACb,mBAAmB,EACnB,EAAE,CACH,CAAC;IACF,MAAM,QAAQ,GAAG,IAAA,8BAAY,EAAC,YAAY,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1C,KAAK,CAAC,MAAM,CACV,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAC3C,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAC9B,CACF,CAAC;IACF,OAAO,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -3,7 +3,5 @@ export declare function settingsText(...segments: string[]): string;
|
|
|
3
3
|
export declare const CODEX_PROVIDER = "codex";
|
|
4
4
|
export declare const PROVIDER_OPTIONS: VocabularyOption[];
|
|
5
5
|
export declare const THINKING_OPTIONS: VocabularyOption[];
|
|
6
|
-
export declare const CLAUDE_MODE_OPTIONS: VocabularyOption[];
|
|
7
|
-
export declare const CODEX_MODE_OPTIONS: VocabularyOption[];
|
|
8
6
|
export declare const REQUEST_TIMEOUT_OPTIONS: VocabularyOption[];
|
|
9
7
|
export declare const RETENTION_OPTIONS: VocabularyOption[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RETENTION_OPTIONS = exports.REQUEST_TIMEOUT_OPTIONS = exports.
|
|
3
|
+
exports.RETENTION_OPTIONS = exports.REQUEST_TIMEOUT_OPTIONS = exports.THINKING_OPTIONS = exports.PROVIDER_OPTIONS = exports.CODEX_PROVIDER = void 0;
|
|
4
4
|
exports.settingsText = settingsText;
|
|
5
5
|
const i18n_1 = require("../../constants/i18n");
|
|
6
6
|
const vocabulary_1 = require("../../vocabulary");
|
|
@@ -9,10 +9,10 @@ function settingsText(...segments) {
|
|
|
9
9
|
return (0, vocabulary_1.i18nKey)(SECTION, ...segments);
|
|
10
10
|
}
|
|
11
11
|
function choices(field, declarations) {
|
|
12
|
-
return declarations.map(({ value, icon,
|
|
12
|
+
return declarations.map(({ value, icon, disabled }) => ({
|
|
13
13
|
value,
|
|
14
14
|
label: settingsText(field, value, "label"),
|
|
15
|
-
description: settingsText(field, value,
|
|
15
|
+
description: settingsText(field, value, "description"),
|
|
16
16
|
icon,
|
|
17
17
|
disabled,
|
|
18
18
|
}));
|
|
@@ -34,33 +34,6 @@ exports.THINKING_OPTIONS = labels("thinking", [
|
|
|
34
34
|
"medium",
|
|
35
35
|
"high",
|
|
36
36
|
]);
|
|
37
|
-
const NORMAL_MODE = {
|
|
38
|
-
value: "normal",
|
|
39
|
-
icon: "i-ph-hand-palm",
|
|
40
|
-
};
|
|
41
|
-
const AUTO_REVIEW_MODE = {
|
|
42
|
-
value: "auto",
|
|
43
|
-
icon: "i-ph-seal-check",
|
|
44
|
-
};
|
|
45
|
-
const ACCEPT_EDITS_MODE = {
|
|
46
|
-
value: "acceptEdits",
|
|
47
|
-
icon: "i-ph-pencil-simple-line",
|
|
48
|
-
};
|
|
49
|
-
const PLAN_MODE = {
|
|
50
|
-
value: "plan",
|
|
51
|
-
icon: "i-ph-list-checks",
|
|
52
|
-
};
|
|
53
|
-
exports.CLAUDE_MODE_OPTIONS = choices("mode", [
|
|
54
|
-
NORMAL_MODE,
|
|
55
|
-
AUTO_REVIEW_MODE,
|
|
56
|
-
ACCEPT_EDITS_MODE,
|
|
57
|
-
PLAN_MODE,
|
|
58
|
-
]);
|
|
59
|
-
exports.CODEX_MODE_OPTIONS = choices("mode", [
|
|
60
|
-
NORMAL_MODE,
|
|
61
|
-
{ ...ACCEPT_EDITS_MODE, descriptionKey: "description_codex" },
|
|
62
|
-
PLAN_MODE,
|
|
63
|
-
]);
|
|
64
37
|
exports.REQUEST_TIMEOUT_OPTIONS = labels("request_timeout", [
|
|
65
38
|
"5",
|
|
66
39
|
"15",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/pages/settings/options.ts"],"names":[],"mappings":";;;AAMA,oCAEC;AARD,+CAAqD;AACrD,iDAAkE;AAElE,MAAM,OAAO,GAAG,oBAAa,CAAC,QAAQ,CAAC;AAGvC,SAAgB,YAAY,CAAC,GAAG,QAAkB;IAChD,OAAO,IAAA,oBAAO,EAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC;AACvC,CAAC;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/pages/settings/options.ts"],"names":[],"mappings":";;;AAMA,oCAEC;AARD,+CAAqD;AACrD,iDAAkE;AAElE,MAAM,OAAO,GAAG,oBAAa,CAAC,QAAQ,CAAC;AAGvC,SAAgB,YAAY,CAAC,GAAG,QAAkB;IAChD,OAAO,IAAA,oBAAO,EAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC;AACvC,CAAC;AAUD,SAAS,OAAO,CACd,KAAa,EACb,YAA0C;IAE1C,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QACtD,KAAK;QACL,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC;QAC1C,WAAW,EAAE,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC;QACtD,IAAI;QACJ,QAAQ;KACT,CAAC,CAAC,CAAC;AACN,CAAC;AAGD,SAAS,MAAM,CAAC,KAAa,EAAE,MAAyB;IACtD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5B,KAAK;QACL,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC;KAC7C,CAAC,CAAC,CAAC;AACN,CAAC;AAEY,QAAA,cAAc,GAAG,OAAO,CAAC;AAEzB,QAAA,gBAAgB,GAAG,OAAO,CAAC,UAAU,EAAE;IAClD,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE;IACvC,EAAE,KAAK,EAAE,sBAAc,EAAE,IAAI,EAAE,YAAY,EAAE;CAC9C,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAG,MAAM,CAAC,UAAU,EAAE;IACjD,KAAK;IACL,KAAK;IACL,QAAQ;IACR,MAAM;CACP,CAAC,CAAC;AAGU,QAAA,uBAAuB,GAAG,MAAM,CAAC,iBAAiB,EAAE;IAC/D,GAAG;IACH,IAAI;IACJ,IAAI;CACL,CAAC,CAAC;AAEU,QAAA,iBAAiB,GAAG,MAAM,CAAC,sBAAsB,EAAE;IAC9D,GAAG;IACH,IAAI;IACJ,IAAI;CACL,CAAC,CAAC"}
|
|
@@ -7,6 +7,7 @@ export declare class AISettingsPage extends AISettingsPage_base {
|
|
|
7
7
|
static attention: import("@antelopejs/interface-dms").ComponentBuilder<import("@antelopejs/interface-dms/base").BannerProps>;
|
|
8
8
|
static chatgpt: import("@antelopejs/interface-dms").ComponentBuilder<import("@antelopejs/interface-dms/base").BannerProps>;
|
|
9
9
|
static settings: import("@antelopejs/interface-dms/base").FormBuilder;
|
|
10
|
+
static guardRails: import("@antelopejs/interface-dms").ComponentBuilder<unknown>;
|
|
10
11
|
static usage: import("@antelopejs/interface-dms").ComponentBuilder<import("@antelopejs/interface-dms/base").SectionProps>;
|
|
11
12
|
}
|
|
12
13
|
export {};
|
|
@@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.AISettingsPage = void 0;
|
|
10
10
|
const base_1 = require("@antelopejs/interface-dms/base");
|
|
11
|
+
const custom_1 = require("@antelopejs/interface-dms/base/custom");
|
|
11
12
|
const layouts_1 = require("@antelopejs/interface-dms/base/layouts");
|
|
12
13
|
const page_1 = require("@antelopejs/interface-dms/page");
|
|
13
14
|
const pages_1 = require("../../constants/pages");
|
|
@@ -29,6 +30,7 @@ let AISettingsPage = class AISettingsPage extends (0, page_1.PageController)(pag
|
|
|
29
30
|
static attention = (0, base_1.Banner)({ fetchUrl: pages_1.PAGE_ROUTES.STATUS_BANNER }).meta((0, meta_1.blockMeta)("settings.status_banner", "i-ph-bell-ringing"));
|
|
30
31
|
static chatgpt = (0, base_1.Banner)({ fetchUrl: pages_1.PAGE_ROUTES.CODEX_ACCOUNT_BANNER }).meta((0, meta_1.blockMeta)("settings.chatgpt", "i-ph-open-ai-logo"));
|
|
31
32
|
static settings = settingsForm;
|
|
33
|
+
static guardRails = (0, custom_1.CustomComponent)("DmsAssistantGuardRails").meta((0, meta_1.blockMeta)("settings.guard_rails", "i-ph-shield-check"));
|
|
32
34
|
static usage = (0, base_1.Section)({
|
|
33
35
|
title: (0, meta_1.blockText)(USAGE_PATH, "title"),
|
|
34
36
|
description: (0, meta_1.blockText)(USAGE_PATH, "caption"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../../src/pages/settings/page.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yDAOwC;AACxC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AU,EAAE,KAAK,EAAE,eAAQ,EAAE,CAAC,CAAC,IAAI,CACjE,IAAA,gBAAS,EAAC,6BAA6B,EAAE,gBAAgB,CAAC,CAC3D;KACF,CAAC,CAAC,IAAI,CAAC,IAAA,gBAAS,EAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAC,CAC7D;SACA,KAAK,CACJ,SAAS,EACT,IAAA,mBAAY,EAAC;QACX,KAAK,EAAE,IAAA,gBAAS,EAAC,wBAAwB,EAAE,OAAO,CAAC;QACnD,QAAQ,EAAE,mBAAW,CAAC,aAAa;QACnC,aAAa,EAAE,kBAAkB;KAClC,CAAC,CAAC,IAAI,CAAC,IAAA,gBAAS,EAAC,wBAAwB,EAAE,mBAAmB,CAAC,CAAC,CAClE,CAAC;;AA9CO,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAY,GAAE;GACF,cAAc,CA+C1B"}
|
|
@@ -5,7 +5,6 @@ const data_types_1 = require("@antelopejs/interface-dms/base/data-types");
|
|
|
5
5
|
const options_1 = require("./options");
|
|
6
6
|
const NEXT_TURN_HINT = (0, options_1.settingsText)("hints", "next_turn");
|
|
7
7
|
const NEXT_MESSAGE_HINT = (0, options_1.settingsText)("hints", "next_message");
|
|
8
|
-
const NEW_CONVERSATIONS_HINT = (0, options_1.settingsText)("hints", "new_conversations");
|
|
9
8
|
function switchType(field) {
|
|
10
9
|
return new data_types_1.DefaultDataTypes.BooleanType({
|
|
11
10
|
label: (0, options_1.settingsText)(field, "label"),
|
|
@@ -44,30 +43,6 @@ const THINKING_FIELD = {
|
|
|
44
43
|
}),
|
|
45
44
|
required: true,
|
|
46
45
|
};
|
|
47
|
-
const DEFAULT_MODE_FIELDS = [
|
|
48
|
-
{
|
|
49
|
-
id: "defaultModeClaude",
|
|
50
|
-
label: (0, options_1.settingsText)("default_mode_claude", "label"),
|
|
51
|
-
description: (0, options_1.settingsText)("default_mode_claude", "description"),
|
|
52
|
-
hint: NEW_CONVERSATIONS_HINT,
|
|
53
|
-
type: new data_types_1.DefaultDataTypes.SelectType({
|
|
54
|
-
display: "cards",
|
|
55
|
-
items: options_1.CLAUDE_MODE_OPTIONS,
|
|
56
|
-
}),
|
|
57
|
-
required: true,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
id: "defaultModeCodex",
|
|
61
|
-
label: (0, options_1.settingsText)("default_mode_codex", "label"),
|
|
62
|
-
description: (0, options_1.settingsText)("default_mode_codex", "description"),
|
|
63
|
-
hint: NEW_CONVERSATIONS_HINT,
|
|
64
|
-
type: new data_types_1.DefaultDataTypes.SelectType({
|
|
65
|
-
display: "cards",
|
|
66
|
-
items: options_1.CODEX_MODE_OPTIONS,
|
|
67
|
-
}),
|
|
68
|
-
required: true,
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
46
|
const UNANSWERED_GROUP = {
|
|
72
47
|
id: "unanswered",
|
|
73
48
|
label: (0, options_1.settingsText)("unanswered", "label"),
|
|
@@ -85,59 +60,12 @@ const UNANSWERED_GROUP = {
|
|
|
85
60
|
{ id: "notifyRequests", type: switchType("notify_requests") },
|
|
86
61
|
],
|
|
87
62
|
};
|
|
88
|
-
const LOCAL_SKILLS_FIELD = {
|
|
89
|
-
id: "allowLocalSkills",
|
|
90
|
-
label: (0, options_1.settingsText)("allow_local_skills", "title"),
|
|
91
|
-
hint: NEW_CONVERSATIONS_HINT,
|
|
92
|
-
type: switchType("allow_local_skills"),
|
|
93
|
-
};
|
|
94
63
|
const AI = {
|
|
95
64
|
id: "ai",
|
|
96
65
|
label: (0, options_1.settingsText)("sections", "ai", "label"),
|
|
97
66
|
description: (0, options_1.settingsText)("sections", "ai", "description"),
|
|
98
67
|
icon: "i-ph-sparkle",
|
|
99
|
-
fields: [
|
|
100
|
-
PROVIDER_FIELD,
|
|
101
|
-
MODEL_FIELD,
|
|
102
|
-
THINKING_FIELD,
|
|
103
|
-
...DEFAULT_MODE_FIELDS,
|
|
104
|
-
UNANSWERED_GROUP,
|
|
105
|
-
LOCAL_SKILLS_FIELD,
|
|
106
|
-
],
|
|
107
|
-
};
|
|
108
|
-
const SAFE_MODE_FIELD = {
|
|
109
|
-
id: "safeMode",
|
|
110
|
-
label: (0, options_1.settingsText)("safe_mode", "label"),
|
|
111
|
-
description: (0, options_1.settingsText)("safe_mode", "description"),
|
|
112
|
-
hint: NEW_CONVERSATIONS_HINT,
|
|
113
|
-
type: switchType("safe_mode"),
|
|
114
|
-
};
|
|
115
|
-
const ALWAYS_ASK_GROUP = {
|
|
116
|
-
id: "alwaysAsk",
|
|
117
|
-
label: (0, options_1.settingsText)("always_ask", "label"),
|
|
118
|
-
description: (0, options_1.settingsText)("always_ask", "description"),
|
|
119
|
-
orientation: "vertical",
|
|
120
|
-
fields: [
|
|
121
|
-
{
|
|
122
|
-
id: "alwaysAskDeletions",
|
|
123
|
-
label: (0, options_1.settingsText)("always_ask_deletions", "label"),
|
|
124
|
-
type: switchType("always_ask_deletions"),
|
|
125
|
-
readonly: {
|
|
126
|
-
badge: {
|
|
127
|
-
label: (0, options_1.settingsText)("always_ask_deletions", "locked"),
|
|
128
|
-
tone: "neutral",
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
id: "alwaysAskDependencies",
|
|
134
|
-
type: switchType("always_ask_dependencies"),
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
id: "alwaysAskBlockRemoval",
|
|
138
|
-
type: switchType("always_ask_block_removal"),
|
|
139
|
-
},
|
|
140
|
-
],
|
|
68
|
+
fields: [PROVIDER_FIELD, MODEL_FIELD, THINKING_FIELD, UNANSWERED_GROUP],
|
|
141
69
|
};
|
|
142
70
|
const RETENTION_FIELD = {
|
|
143
71
|
id: "checkpointRetentionDays",
|
|
@@ -151,7 +79,7 @@ const BUILDER = {
|
|
|
151
79
|
label: (0, options_1.settingsText)("sections", "builder", "label"),
|
|
152
80
|
description: (0, options_1.settingsText)("sections", "builder", "description"),
|
|
153
81
|
icon: "i-ph-hammer",
|
|
154
|
-
fields: [
|
|
82
|
+
fields: [RETENTION_FIELD],
|
|
155
83
|
};
|
|
156
84
|
exports.SETTINGS_SECTIONS = [AI, BUILDER];
|
|
157
85
|
//# sourceMappingURL=sections.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sections.js","sourceRoot":"","sources":["../../../src/pages/settings/sections.ts"],"names":[],"mappings":";;;AAAA,0EAA6E;AAM7E,
|
|
1
|
+
{"version":3,"file":"sections.js","sourceRoot":"","sources":["../../../src/pages/settings/sections.ts"],"names":[],"mappings":";;;AAAA,0EAA6E;AAM7E,uCAMmB;AAEnB,MAAM,cAAc,GAAG,IAAA,sBAAY,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAC1D,MAAM,iBAAiB,GAAG,IAAA,sBAAY,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAEhE,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,IAAI,6BAAgB,CAAC,WAAW,CAAC;QACtC,KAAK,EAAE,IAAA,sBAAY,EAAC,KAAK,EAAE,OAAO,CAAC;QACnC,WAAW,EAAE,IAAA,sBAAY,EAAC,KAAK,EAAE,aAAa,CAAC;KAChD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,cAAc,GAAc;IAChC,EAAE,EAAE,UAAU;IACd,KAAK,EAAE,IAAA,sBAAY,EAAC,UAAU,EAAE,OAAO,CAAC;IACxC,WAAW,EAAE,IAAA,sBAAY,EAAC,UAAU,EAAE,aAAa,CAAC;IACpD,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,IAAI,6BAAgB,CAAC,UAAU,CAAC;QACpC,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,0BAAgB;KACxB,CAAC;IACF,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF,MAAM,WAAW,GAAc;IAC7B,EAAE,EAAE,aAAa;IACjB,KAAK,EAAE,IAAA,sBAAY,EAAC,cAAc,EAAE,OAAO,CAAC;IAC5C,WAAW,EAAE,I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AAU,EAAE,IAAI,EAAE,aAAa,CAAC;IAC1D,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,CAAC,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,CAAC;CACxE,CAAC;AAEF,MAAM,eAAe,GAAc;IACjC,EAAE,EAAE,yBAAyB;IAC7B,KAAK,EAAE,IAAA,sBAAY,EAAC,sBAAsB,EAAE,OAAO,CAAC;IACpD,WAAW,EAAE,IAAA,sBAAY,EAAC,sBAAsB,EAAE,aAAa,CAAC;IAChE,IAAI,EAAE,IAAI,6BAAgB,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,2BAAiB,EAAE,CAAC;IACnE,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF,MAAM,OAAO,GAAgB;IAC3B,EAAE,EAAE,SAAS;IACb,KAAK,EAAE,IAAA,sBAAY,EAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;IACnD,WAAW,EAAE,IAAA,sBAAY,EAAC,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC;IAC/D,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,CAAC,eAAe,CAAC;CAC1B,CAAC;AAOW,QAAA,iBAAiB,GAAkB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -3,6 +3,6 @@ import { type SettingsBody } from "../sidecar/settings-values";
|
|
|
3
3
|
declare const AISettingsController_base: import("@antelopejs/interface-api").ControllerClass<object>;
|
|
4
4
|
export declare class AISettingsController extends AISettingsController_base {
|
|
5
5
|
getSettings(): Promise<SettingsBody | HTTPResult>;
|
|
6
|
-
updateSettings(body
|
|
6
|
+
updateSettings(body: SettingsBody | undefined, marker: string | undefined): Promise<SettingsBody | HTTPResult>;
|
|
7
7
|
}
|
|
8
8
|
export {};
|
package/dist/routes/settings.js
CHANGED
|
@@ -17,6 +17,7 @@ const interface_api_1 = require("@antelopejs/interface-api");
|
|
|
17
17
|
const auth_1 = require("@antelopejs/interface-dms/auth");
|
|
18
18
|
const module_1 = require("../constants/module");
|
|
19
19
|
const settings_values_1 = require("../sidecar/settings-values");
|
|
20
|
+
const owner_ui_1 = require("./owner-ui");
|
|
20
21
|
const sidecar_results_1 = require("./sidecar-results");
|
|
21
22
|
const sidecar_answers_1 = require("./sidecar-answers");
|
|
22
23
|
const SETTINGS_PATH = "/settings";
|
|
@@ -27,6 +28,17 @@ const READ_ONLY_SETTINGS = [
|
|
|
27
28
|
"defaults",
|
|
28
29
|
];
|
|
29
30
|
const ALWAYS_ASK_DELETIONS = true;
|
|
31
|
+
const FREE_SETTINGS = new Set([
|
|
32
|
+
"provider",
|
|
33
|
+
"thinking",
|
|
34
|
+
"claudeModel",
|
|
35
|
+
"requestTimeoutMinutes",
|
|
36
|
+
"notifyRequests",
|
|
37
|
+
"checkpointRetentionDays",
|
|
38
|
+
]);
|
|
39
|
+
function writesGuardRail(update) {
|
|
40
|
+
return Object.keys(update).some((key) => !FREE_SETTINGS.has(key));
|
|
41
|
+
}
|
|
30
42
|
function formSettings(settings) {
|
|
31
43
|
return {
|
|
32
44
|
...(0, settings_values_1.asFormValues)(settings),
|
|
@@ -43,10 +55,16 @@ let AISettingsController = class AISettingsController extends (0, interface_api_
|
|
|
43
55
|
getSettings() {
|
|
44
56
|
return (0, sidecar_results_1.relay)(SETTINGS_PATH, sidecar_answers_1.SETTINGS_ANSWER, formSettings);
|
|
45
57
|
}
|
|
46
|
-
updateSettings(body) {
|
|
58
|
+
async updateSettings(body, marker) {
|
|
59
|
+
const update = sidecarUpdate(body ?? {});
|
|
60
|
+
const refused = writesGuardRail(update)
|
|
61
|
+
? (0, owner_ui_1.outsideOwnerUi)(marker)
|
|
62
|
+
: undefined;
|
|
63
|
+
if (refused)
|
|
64
|
+
return refused;
|
|
47
65
|
return (0, sidecar_results_1.relay)(SETTINGS_PATH, sidecar_answers_1.SETTINGS_ANSWER, formSettings, {
|
|
48
66
|
method: "PUT",
|
|
49
|
-
body:
|
|
67
|
+
body: update,
|
|
50
68
|
});
|
|
51
69
|
}
|
|
52
70
|
};
|
|
@@ -60,8 +78,9 @@ __decorate([
|
|
|
60
78
|
__decorate([
|
|
61
79
|
(0, interface_api_1.Put)(SETTINGS_PATH),
|
|
62
80
|
__param(0, (0, interface_api_1.JSONBody)()),
|
|
81
|
+
__param(1, (0, interface_api_1.Parameter)(owner_ui_1.OWNER_UI_HEADER, "header")),
|
|
63
82
|
__metadata("design:type", Function),
|
|
64
|
-
__metadata("design:paramtypes", [Object]),
|
|
83
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
65
84
|
__metadata("design:returntype", Promise)
|
|
66
85
|
], AISettingsController.prototype, "updateSettings", null);
|
|
67
86
|
exports.AISettingsController = AISettingsController = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/routes/settings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/routes/settings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAOmC;AACnC,yDAA+D;AAC/D,gDAAmD;AACnD,gEAMoC;AACpC,yCAA6D;AAC7D,uDAA0C;AAC1C,uDAAoD;AAEpD,MAAM,aAAa,GAAG,WAAW,CAAC;AAGlC,MAAM,kBAAkB,GAAG;IACzB,kBAAkB;IAClB,WAAW;IACX,oBAAoB;IACpB,UAAU;CACF,CAAC;AAGX,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAQlC,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC;IACjD,UAAU;IACV,UAAU;IACV,aAAa;IACb,uBAAuB;IACvB,gBAAgB;IAChB,yBAAyB;CAC1B,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,MAAoB;IAC3C,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,G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ACV,WAAA,IAAA,yBAAS,EAAC,0BAAe,EAAE,QAAQ,CAAC,CAAA;;;;0DAWtC;+BApBU,oBAAoB;IADhC,IAAA,oBAAa,GAAE;GACH,oBAAoB,CAqBhC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import UnavailableState from "../views/UnavailableState.vue";
|
|
4
|
+
import { useGuardRails } from "../views/composables/useGuardRails";
|
|
5
|
+
import {
|
|
6
|
+
LOCKED_SWITCH_FIELD,
|
|
7
|
+
MODE_ROWS,
|
|
8
|
+
SWITCH_ROWS,
|
|
9
|
+
modeOf,
|
|
10
|
+
type ModeRow,
|
|
11
|
+
type SwitchRow,
|
|
12
|
+
} from "../views/guard-rails";
|
|
13
|
+
|
|
14
|
+
const { t } = useI18n();
|
|
15
|
+
const guard = useGuardRails();
|
|
16
|
+
|
|
17
|
+
function settingsText(...segments: string[]): string {
|
|
18
|
+
return t(["dms_assistant", "settings", ...segments].join("."));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const hint = computed(() => settingsText("hints", "new_conversations"));
|
|
22
|
+
|
|
23
|
+
const MODE_CARDS_UI = { fieldset: "grid gap-2.5 sm:grid-cols-2" };
|
|
24
|
+
|
|
25
|
+
function modeItems(row: ModeRow) {
|
|
26
|
+
return row.modes.map((mode) => ({
|
|
27
|
+
value: mode,
|
|
28
|
+
label: settingsText("mode", mode, "label"),
|
|
29
|
+
description: settingsText(
|
|
30
|
+
"mode",
|
|
31
|
+
mode,
|
|
32
|
+
row.provider === "codex" && mode === "acceptEdits"
|
|
33
|
+
? "description_codex"
|
|
34
|
+
: "description",
|
|
35
|
+
),
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function pickMode(row: ModeRow, value: unknown): void {
|
|
40
|
+
const mode = modeOf(row, value);
|
|
41
|
+
if (mode) void guard.save(row.field, mode);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Safe mode needs the Builder: without it the switch stays, off, saying why. */
|
|
45
|
+
function isBuilderMissing(row: SwitchRow): boolean {
|
|
46
|
+
return (
|
|
47
|
+
row.field === "safeMode" && guard.values.value?.builderAvailable === false
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function switchDescription(row: SwitchRow): string {
|
|
52
|
+
return settingsText(
|
|
53
|
+
row.text,
|
|
54
|
+
isBuilderMissing(row) ? "builder_missing" : "description",
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function switchAriaLabel(row: SwitchRow): string {
|
|
59
|
+
return settingsText(
|
|
60
|
+
row.text,
|
|
61
|
+
row.field === LOCKED_SWITCH_FIELD ? "locked" : "label",
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function isSwitchDisabled(row: SwitchRow): boolean {
|
|
66
|
+
return (
|
|
67
|
+
row.field === LOCKED_SWITCH_FIELD ||
|
|
68
|
+
isBuilderMissing(row) ||
|
|
69
|
+
guard.isSaving(row.field)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function pickSwitch(row: SwitchRow, value: boolean): void {
|
|
74
|
+
if (row.field !== LOCKED_SWITCH_FIELD) void guard.save(row.field, value);
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<template>
|
|
79
|
+
<DmsCardPanel
|
|
80
|
+
v-if="!guard.isTurnedOff.value"
|
|
81
|
+
:padded="false"
|
|
82
|
+
:title="t('dms_assistant.views.guard_rails.title')"
|
|
83
|
+
>
|
|
84
|
+
<UnavailableState
|
|
85
|
+
v-if="guard.failure.value && !guard.values.value"
|
|
86
|
+
:failure="guard.failure.value"
|
|
87
|
+
:message="guard.message.value"
|
|
88
|
+
@retry="guard.reload"
|
|
89
|
+
/>
|
|
90
|
+
<div
|
|
91
|
+
v-else-if="!guard.values.value"
|
|
92
|
+
class="flex flex-col gap-4 p-5"
|
|
93
|
+
:aria-busy="true"
|
|
94
|
+
:aria-label="t('dms_assistant.views.common.loading')"
|
|
95
|
+
>
|
|
96
|
+
<USkeleton v-for="index in 4" :key="index" class="h-10 w-full" />
|
|
97
|
+
</div>
|
|
98
|
+
<div v-else class="flex flex-col">
|
|
99
|
+
<p class="text-muted px-5 pt-4 text-[12.5px]/normal">
|
|
100
|
+
{{ t("dms_assistant.views.guard_rails.description") }}
|
|
101
|
+
</p>
|
|
102
|
+
<DmsFieldRow
|
|
103
|
+
v-for="row in MODE_ROWS"
|
|
104
|
+
:key="row.field"
|
|
105
|
+
layout="stack"
|
|
106
|
+
:label="settingsText(row.text, 'label')"
|
|
107
|
+
:description="settingsText(row.text, 'description')"
|
|
108
|
+
>
|
|
109
|
+
<div class="flex flex-col gap-2">
|
|
110
|
+
<URadioGroup
|
|
111
|
+
:model-value="guard.values.value[row.field]"
|
|
112
|
+
:items="modeItems(row)"
|
|
113
|
+
:disabled="guard.isSaving(row.field)"
|
|
114
|
+
:aria-label="settingsText(row.text, 'label')"
|
|
115
|
+
variant="card"
|
|
116
|
+
:ui="MODE_CARDS_UI"
|
|
117
|
+
@update:model-value="pickMode(row, $event)"
|
|
118
|
+
/>
|
|
119
|
+
<p class="text-dimmed text-[12px]/normal">{{ hint }}</p>
|
|
120
|
+
</div>
|
|
121
|
+
</DmsFieldRow>
|
|
122
|
+
<template v-for="row in SWITCH_ROWS" :key="row.field">
|
|
123
|
+
<div v-if="row.startsAlwaysAsk" class="px-5 pt-4">
|
|
124
|
+
<b class="text-highlighted block text-[13px] font-semibold">
|
|
125
|
+
{{ settingsText("always_ask", "label") }}
|
|
126
|
+
</b>
|
|
127
|
+
<span class="text-muted block text-[12.5px]/normal">
|
|
128
|
+
{{ settingsText("always_ask", "description") }}
|
|
129
|
+
</span>
|
|
130
|
+
</div>
|
|
131
|
+
<DmsFieldRow
|
|
132
|
+
:label="settingsText(row.text, row.title)"
|
|
133
|
+
:description="switchDescription(row)"
|
|
134
|
+
>
|
|
135
|
+
<USwitch
|
|
136
|
+
:model-value="guard.values.value[row.field]"
|
|
137
|
+
:disabled="isSwitchDisabled(row)"
|
|
138
|
+
:aria-label="switchAriaLabel(row)"
|
|
139
|
+
@update:model-value="pickSwitch(row, $event)"
|
|
140
|
+
/>
|
|
141
|
+
<template v-if="row.hasHint" #details>
|
|
142
|
+
<span class="text-dimmed text-[12px]/normal">{{ hint }}</span>
|
|
143
|
+
</template>
|
|
144
|
+
</DmsFieldRow>
|
|
145
|
+
</template>
|
|
146
|
+
</div>
|
|
147
|
+
</DmsCardPanel>
|
|
148
|
+
</template>
|
|
@@ -77,6 +77,8 @@ import { mountFoldBar } from "../runtime/fold-bar";
|
|
|
77
77
|
import { createFrameRouter } from "../runtime/frame-router";
|
|
78
78
|
import {
|
|
79
79
|
createHostCommandDispatcher,
|
|
80
|
+
createNavigator,
|
|
81
|
+
type Navigator,
|
|
80
82
|
type HostCommandDispatcher,
|
|
81
83
|
} from "../runtime/host-commands";
|
|
82
84
|
import {
|
|
@@ -272,6 +274,7 @@ interface SessionParts {
|
|
|
272
274
|
activity: AssistantActivity;
|
|
273
275
|
launcher: LauncherStateHandle;
|
|
274
276
|
currentPage: Ref<CurrentPage | null>;
|
|
277
|
+
navigate: Navigator;
|
|
275
278
|
}
|
|
276
279
|
|
|
277
280
|
function createSession(parts: SessionParts): AssistantSession {
|
|
@@ -281,7 +284,7 @@ function createSession(parts: SessionParts): AssistantSession {
|
|
|
281
284
|
status: parts.status,
|
|
282
285
|
chat: parts.chat.transport,
|
|
283
286
|
panel,
|
|
284
|
-
navigate:
|
|
287
|
+
navigate: parts.navigate,
|
|
285
288
|
openConversation: (conversationId) => {
|
|
286
289
|
intents.push({ kind: "open", conversationId });
|
|
287
290
|
panel.open();
|
|
@@ -448,10 +451,12 @@ function createRuntime(
|
|
|
448
451
|
deps: DashboardDeps,
|
|
449
452
|
controller: SidecarStatusController,
|
|
450
453
|
): AssistantRuntime {
|
|
451
|
-
const
|
|
454
|
+
const navigate = createNavigator({
|
|
452
455
|
router: deps.router,
|
|
453
456
|
devReload: deps.devReload,
|
|
457
|
+
location: () => window.location.pathname,
|
|
454
458
|
});
|
|
459
|
+
const dispatchHostCommand = createHostCommandDispatcher({ navigate });
|
|
455
460
|
const { client, chat } = createAssistantChannel({
|
|
456
461
|
$authFetch: deps.$authFetch,
|
|
457
462
|
controller,
|
|
@@ -494,6 +499,7 @@ function createRuntime(
|
|
|
494
499
|
activity,
|
|
495
500
|
launcher,
|
|
496
501
|
currentPage,
|
|
502
|
+
navigate,
|
|
497
503
|
});
|
|
498
504
|
const stops = [
|
|
499
505
|
installToggleShortcut({ onToggle: panel.toggle }),
|
|
@@ -31,7 +31,10 @@ export interface AssistantSession {
|
|
|
31
31
|
status: Readonly<Ref<SidecarStatus>>;
|
|
32
32
|
chat: ChatTransport;
|
|
33
33
|
panel: ChatPanelState;
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Opens a page of the dashboard once its site layout serves it, so a page the builder or the
|
|
36
|
+
* agent just wrote opens without a 404; navigations share the agent's queue.
|
|
37
|
+
*/
|
|
35
38
|
navigate: (path: string) => void;
|
|
36
39
|
/** Opens the panel on that conversation. */
|
|
37
40
|
openConversation: (conversationId: string) => void;
|
|
@@ -14,9 +14,49 @@ export interface DevReloadWaiter {
|
|
|
14
14
|
awaitRoute: (path: string) => Promise<boolean>;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* How many of the host's waits, of 15 s each, a navigation spends on its route. A page the builder
|
|
19
|
+
* writes changes the project's configuration, so the whole project restarts before it serves the
|
|
20
|
+
* page: measured from 10 s to 22 s under `ajs project dev -w`, past one wait. Each wait holds the
|
|
21
|
+
* host's single refresh no longer than its own default, and a known route answers at once.
|
|
22
|
+
*/
|
|
23
|
+
const ROUTE_WAITS = 4;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The most a navigation waits in all, whatever the host's waits last: a burst of reloads can make
|
|
27
|
+
* one of them run past its own 15 s. The sidecar's `navigate_to_page` budget outlasts it.
|
|
28
|
+
*/
|
|
29
|
+
const TRIP_WAIT_MS = 60_000;
|
|
30
|
+
|
|
31
|
+
/** Resolves `false` after `ms`, or never once `cancel` ran. */
|
|
32
|
+
function lapse(ms: number): { lapsed: Promise<boolean>; cancel: () => void } {
|
|
33
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
34
|
+
const lapsed = new Promise<boolean>((resolve) => {
|
|
35
|
+
timer = setTimeout(() => resolve(false), ms);
|
|
36
|
+
});
|
|
37
|
+
return { lapsed, cancel: () => clearTimeout(timer) };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** What navigating the dashboard needs: its router, the host's dev reload, and where it is now. */
|
|
41
|
+
export interface NavigationContext {
|
|
18
42
|
router: RouterLike;
|
|
19
43
|
devReload: DevReloadWaiter;
|
|
44
|
+
/** The dashboard's current path: a trip whose page changed meanwhile does not push. */
|
|
45
|
+
location: () => string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Sends the dashboard to an in-app path once the host's committed site layout serves it. A page
|
|
50
|
+
* the builder or the agent just wrote is re-registered by a module reload, and a push before the
|
|
51
|
+
* layout lists it lands on a 404. A newer path supersedes the trips still waiting, and so does a
|
|
52
|
+
* page the user opened meanwhile, so the dashboard never moves back to an older target; a page that
|
|
53
|
+
* exists opens at once whatever waits before it. A lapsed or broken wait still navigates, so a page
|
|
54
|
+
* that never comes 404s.
|
|
55
|
+
*/
|
|
56
|
+
export type Navigator = (path: string) => void;
|
|
57
|
+
|
|
58
|
+
export interface HostCommandContext {
|
|
59
|
+
navigate: Navigator;
|
|
20
60
|
}
|
|
21
61
|
|
|
22
62
|
interface HostCommandNavigateMessage {
|
|
@@ -29,55 +69,52 @@ type HostCommandMessage = HostCommandNavigateMessage;
|
|
|
29
69
|
/** Takes a sidecar message already parsed; anything that is not a host command is ignored. */
|
|
30
70
|
export type HostCommandDispatcher = (msg: unknown) => void;
|
|
31
71
|
|
|
32
|
-
/**
|
|
33
|
-
* Commands run one at a time on `tail`. `nextPath` holds the newest navigation
|
|
34
|
-
* target still waiting for a slot, so a burst collapses into a single trip to
|
|
35
|
-
* the latest path instead of racing and landing on the oldest one.
|
|
36
|
-
*/
|
|
37
|
-
interface DispatcherState {
|
|
38
|
-
ctx: HostCommandContext;
|
|
39
|
-
tail: Promise<void>;
|
|
40
|
-
nextPath: string | null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
72
|
type HostCommandHandler = (
|
|
44
73
|
msg: HostCommandMessage,
|
|
45
|
-
|
|
74
|
+
ctx: HostCommandContext,
|
|
46
75
|
) => void;
|
|
47
76
|
|
|
48
77
|
const IN_APP_PATH = /^\/(?![/\\])/;
|
|
49
78
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
79
|
+
/** The page's own route: the site layout lists pages without their query or hash. */
|
|
80
|
+
function routeOf(path: string): string {
|
|
81
|
+
return path.split(/[?#]/, 1)[0] ?? path;
|
|
54
82
|
}
|
|
55
83
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// must not strand the user on the previous page; a genuinely missing page then
|
|
61
|
-
// 404s as it did before.
|
|
62
|
-
async function awaitRouteThenPush(
|
|
63
|
-
path: string,
|
|
64
|
-
ctx: HostCommandContext,
|
|
84
|
+
async function waitForRoute(
|
|
85
|
+
devReload: DevReloadWaiter,
|
|
86
|
+
route: string,
|
|
87
|
+
stillWanted: () => boolean,
|
|
65
88
|
): Promise<void> {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
89
|
+
const deadline = Date.now() + TRIP_WAIT_MS;
|
|
90
|
+
for (let wait = 0; wait < ROUTE_WAITS && stillWanted(); wait += 1) {
|
|
91
|
+
const left = deadline - Date.now();
|
|
92
|
+
if (left <= 0) return;
|
|
93
|
+
const { lapsed, cancel } = lapse(left);
|
|
94
|
+
try {
|
|
95
|
+
if (await Promise.race([devReload.awaitRoute(route), lapsed])) return;
|
|
96
|
+
} finally {
|
|
97
|
+
cancel();
|
|
98
|
+
}
|
|
70
99
|
}
|
|
71
|
-
void ctx.router.push(path);
|
|
72
100
|
}
|
|
73
101
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
export function createNavigator(ctx: NavigationContext): Navigator {
|
|
103
|
+
let newest = 0;
|
|
104
|
+
return (path) => {
|
|
105
|
+
newest += 1;
|
|
106
|
+
const trip = newest;
|
|
107
|
+
const from = ctx.location();
|
|
108
|
+
const stillWanted = (): boolean =>
|
|
109
|
+
trip === newest && ctx.location() === from;
|
|
110
|
+
void waitForRoute(ctx.devReload, routeOf(path), stillWanted)
|
|
111
|
+
.catch((err: unknown) => {
|
|
112
|
+
console.error(`${LOG_PREFIX} dev reload wait failed for ${path}`, err);
|
|
113
|
+
})
|
|
114
|
+
.then(() => {
|
|
115
|
+
if (stillWanted()) void ctx.router.push(path);
|
|
116
|
+
});
|
|
117
|
+
};
|
|
81
118
|
}
|
|
82
119
|
|
|
83
120
|
/**
|
|
@@ -94,28 +131,26 @@ function isInAppPath(path: unknown): path is string {
|
|
|
94
131
|
}
|
|
95
132
|
}
|
|
96
133
|
|
|
97
|
-
function handleNavigate(
|
|
134
|
+
function handleNavigate(
|
|
135
|
+
msg: HostCommandMessage,
|
|
136
|
+
ctx: HostCommandContext,
|
|
137
|
+
): void {
|
|
98
138
|
if (msg.type !== HOST_COMMAND_NAVIGATE_TYPE) return;
|
|
99
139
|
if (!isInAppPath(msg.path)) {
|
|
100
140
|
console.warn(`${LOG_PREFIX} refused to navigate off the dashboard`);
|
|
101
141
|
return;
|
|
102
142
|
}
|
|
103
|
-
|
|
104
|
-
enqueue(state, () => runNavigate(state));
|
|
143
|
+
ctx.navigate(msg.path);
|
|
105
144
|
}
|
|
106
145
|
|
|
107
146
|
const COMMAND_HANDLERS: Record<string, HostCommandHandler> = {
|
|
108
147
|
[HOST_COMMAND_NAVIGATE_TYPE]: handleNavigate,
|
|
109
148
|
};
|
|
110
149
|
|
|
150
|
+
/** Runs the agent's host commands; its navigations go through `ctx.navigate`, the dashboard's own queue. */
|
|
111
151
|
export function createHostCommandDispatcher(
|
|
112
152
|
ctx: HostCommandContext,
|
|
113
153
|
): HostCommandDispatcher {
|
|
114
|
-
const state: DispatcherState = {
|
|
115
|
-
ctx,
|
|
116
|
-
tail: Promise.resolve(),
|
|
117
|
-
nextPath: null,
|
|
118
|
-
};
|
|
119
154
|
return (msg: unknown): void => {
|
|
120
155
|
if (!isTypedMessage<HostCommandMessage>(msg)) return;
|
|
121
156
|
const handler = COMMAND_HANDLERS[msg.type];
|
|
@@ -123,6 +158,6 @@ export function createHostCommandDispatcher(
|
|
|
123
158
|
console.warn(`${LOG_PREFIX} unknown host command type=${msg.type}`);
|
|
124
159
|
return;
|
|
125
160
|
}
|
|
126
|
-
handler(msg,
|
|
161
|
+
handler(msg, ctx);
|
|
127
162
|
};
|
|
128
163
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { computed, ref, watch, type ComputedRef } from "vue";
|
|
2
|
+
import { OWNER_UI_HEADERS } from "../../../builder/app/runtime/owner-ui";
|
|
3
|
+
import { JSON_CONTENT_TYPE } from "../../runtime/constants";
|
|
4
|
+
import { AI_ROUTES } from "../constants";
|
|
5
|
+
import type { GuardRailField, GuardRailValues } from "../guard-rails";
|
|
6
|
+
import type { AssistantStatus } from "../types";
|
|
7
|
+
import { classifyFailure, useAiData, type RequestFailure } from "./useAiData";
|
|
8
|
+
|
|
9
|
+
export interface GuardRails {
|
|
10
|
+
/**
|
|
11
|
+
* The values shown: the confirmed ones, with the value of each save in
|
|
12
|
+
* flight over its field; none until the first read answers.
|
|
13
|
+
*/
|
|
14
|
+
values: ComputedRef<GuardRailValues | null>;
|
|
15
|
+
/** The module's configuration turns the sidecar off: the page's offline banner says so alone. */
|
|
16
|
+
isTurnedOff: ComputedRef<boolean>;
|
|
17
|
+
failure: ComputedRef<RequestFailure | null>;
|
|
18
|
+
message: ComputedRef<string>;
|
|
19
|
+
reload: () => Promise<void>;
|
|
20
|
+
isSaving: (field: GuardRailField) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Saves one field on its own, with the assistant UI's header: the value
|
|
23
|
+
* shows at once, becomes the confirmed one when the save is accepted, and
|
|
24
|
+
* gives way to the confirmed one when the save is refused or fails.
|
|
25
|
+
*/
|
|
26
|
+
save: <Field extends GuardRailField>(
|
|
27
|
+
field: Field,
|
|
28
|
+
value: GuardRailValues[Field],
|
|
29
|
+
) => Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The assistant's own client of the guard-rail settings. It is the one place
|
|
34
|
+
* that writes them: `PUT /ai/settings` takes a guard rail only with the
|
|
35
|
+
* assistant UI's header, which a DMS form's save cannot send.
|
|
36
|
+
*/
|
|
37
|
+
export function useGuardRails(): GuardRails {
|
|
38
|
+
const { $authFetch } = useAuthFetch();
|
|
39
|
+
const { presentError } = useApiErrorPresenter();
|
|
40
|
+
const read = useAiData<GuardRailValues>(AI_ROUTES.settings);
|
|
41
|
+
const status = useAiData<AssistantStatus>(AI_ROUTES.status);
|
|
42
|
+
const confirmed = ref<GuardRailValues | null>(null);
|
|
43
|
+
const pending = ref<Partial<GuardRailValues>>({});
|
|
44
|
+
|
|
45
|
+
watch(
|
|
46
|
+
() => read.data.value,
|
|
47
|
+
(settings) => {
|
|
48
|
+
if (settings) confirmed.value = { ...settings };
|
|
49
|
+
},
|
|
50
|
+
{ immediate: true },
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const values = computed(() =>
|
|
54
|
+
confirmed.value ? { ...confirmed.value, ...pending.value } : null,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
function isSaving(field: GuardRailField): boolean {
|
|
58
|
+
return Object.hasOwn(pending.value, field);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function settle(field: GuardRailField): void {
|
|
62
|
+
pending.value = Object.fromEntries(
|
|
63
|
+
Object.entries(pending.value).filter(([name]) => name !== field),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function save<Field extends GuardRailField>(
|
|
68
|
+
field: Field,
|
|
69
|
+
value: GuardRailValues[Field],
|
|
70
|
+
): Promise<void> {
|
|
71
|
+
if (!confirmed.value || isSaving(field)) return;
|
|
72
|
+
pending.value = { ...pending.value, [field]: value };
|
|
73
|
+
try {
|
|
74
|
+
await $authFetch(AI_ROUTES.settings, {
|
|
75
|
+
method: "PUT",
|
|
76
|
+
body: JSON.stringify({ [field]: value }),
|
|
77
|
+
headers: { "content-type": JSON_CONTENT_TYPE, ...OWNER_UI_HEADERS },
|
|
78
|
+
});
|
|
79
|
+
if (confirmed.value) {
|
|
80
|
+
confirmed.value = {
|
|
81
|
+
...confirmed.value,
|
|
82
|
+
[field]: value,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
} catch (error) {
|
|
86
|
+
presentError(error, {
|
|
87
|
+
fallbackKey:
|
|
88
|
+
classifyFailure(error) === "unavailable"
|
|
89
|
+
? "dms_assistant.views.unavailable.description"
|
|
90
|
+
: "dms_assistant.views.guard_rails.not_saved",
|
|
91
|
+
});
|
|
92
|
+
} finally {
|
|
93
|
+
settle(field);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
values,
|
|
99
|
+
isTurnedOff: computed(() => status.data.value?.disabled === true),
|
|
100
|
+
failure: computed(() => read.failure.value),
|
|
101
|
+
message: computed(() => read.message.value),
|
|
102
|
+
reload: () => read.refresh(),
|
|
103
|
+
isSaving,
|
|
104
|
+
save,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { MODES_BY_PROVIDER } from "../chat/constants/modes";
|
|
2
|
+
import type { ProviderName } from "../chat/types/protocol";
|
|
3
|
+
import type { ApprovalMode } from "./types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* What `GET /ai/settings` answers for the guard rails: the default approval
|
|
7
|
+
* modes, the Safe mode switch, the asks and local skills, with the Builder
|
|
8
|
+
* capability Safe mode needs.
|
|
9
|
+
*/
|
|
10
|
+
export interface GuardRailValues {
|
|
11
|
+
defaultModeClaude: ApprovalMode;
|
|
12
|
+
defaultModeCodex: ApprovalMode;
|
|
13
|
+
safeMode: boolean;
|
|
14
|
+
alwaysAskDeletions: boolean;
|
|
15
|
+
alwaysAskDependencies: boolean;
|
|
16
|
+
alwaysAskBlockRemoval: boolean;
|
|
17
|
+
allowLocalSkills: boolean;
|
|
18
|
+
builderAvailable?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** One provider's default approval mode, saved on its own. */
|
|
22
|
+
export interface ModeRow {
|
|
23
|
+
field: "defaultModeClaude" | "defaultModeCodex";
|
|
24
|
+
/** The modes this provider offers. */
|
|
25
|
+
modes: readonly ApprovalMode[];
|
|
26
|
+
/** The `$dms_assistant.settings` group holding the row's label and description. */
|
|
27
|
+
text: string;
|
|
28
|
+
provider: ProviderName;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const MODE_ROWS: readonly ModeRow[] = [
|
|
32
|
+
{
|
|
33
|
+
field: "defaultModeClaude",
|
|
34
|
+
modes: MODES_BY_PROVIDER.claude,
|
|
35
|
+
text: "default_mode_claude",
|
|
36
|
+
provider: "claude",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
field: "defaultModeCodex",
|
|
40
|
+
modes: MODES_BY_PROVIDER.codex,
|
|
41
|
+
text: "default_mode_codex",
|
|
42
|
+
provider: "codex",
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
/** The switches saved on their own. */
|
|
47
|
+
type SavedSwitchField =
|
|
48
|
+
| "safeMode"
|
|
49
|
+
| "alwaysAskDependencies"
|
|
50
|
+
| "alwaysAskBlockRemoval"
|
|
51
|
+
| "allowLocalSkills";
|
|
52
|
+
|
|
53
|
+
/** The switch shown locked on: deleting always asks. */
|
|
54
|
+
export const LOCKED_SWITCH_FIELD = "alwaysAskDeletions";
|
|
55
|
+
|
|
56
|
+
/** One switch of the card. */
|
|
57
|
+
export interface SwitchRow {
|
|
58
|
+
field: SavedSwitchField | typeof LOCKED_SWITCH_FIELD;
|
|
59
|
+
/** The `$dms_assistant.settings` group holding the row's texts. */
|
|
60
|
+
text: string;
|
|
61
|
+
/** The key of the row's title in that group. */
|
|
62
|
+
title: "label" | "title";
|
|
63
|
+
/** Whether the row says its change applies to new conversations only. */
|
|
64
|
+
hasHint: boolean;
|
|
65
|
+
/** Whether the "always ask" heading opens at this row. */
|
|
66
|
+
startsAlwaysAsk: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const SWITCH_ROWS: readonly SwitchRow[] = [
|
|
70
|
+
{
|
|
71
|
+
field: "safeMode",
|
|
72
|
+
text: "safe_mode",
|
|
73
|
+
title: "label",
|
|
74
|
+
hasHint: true,
|
|
75
|
+
startsAlwaysAsk: false,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
field: LOCKED_SWITCH_FIELD,
|
|
79
|
+
text: "always_ask_deletions",
|
|
80
|
+
title: "label",
|
|
81
|
+
hasHint: false,
|
|
82
|
+
startsAlwaysAsk: true,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
field: "alwaysAskDependencies",
|
|
86
|
+
text: "always_ask_dependencies",
|
|
87
|
+
title: "label",
|
|
88
|
+
hasHint: false,
|
|
89
|
+
startsAlwaysAsk: false,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
field: "alwaysAskBlockRemoval",
|
|
93
|
+
text: "always_ask_block_removal",
|
|
94
|
+
title: "label",
|
|
95
|
+
hasHint: false,
|
|
96
|
+
startsAlwaysAsk: false,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
field: "allowLocalSkills",
|
|
100
|
+
text: "allow_local_skills",
|
|
101
|
+
title: "title",
|
|
102
|
+
hasHint: true,
|
|
103
|
+
startsAlwaysAsk: false,
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
/** A field of the guard rails the card saves on its own. */
|
|
108
|
+
export type GuardRailField = ModeRow["field"] | SavedSwitchField;
|
|
109
|
+
|
|
110
|
+
/** The mode a radio group's value names for the provider, if it offers one. */
|
|
111
|
+
export function modeOf(row: ModeRow, value: unknown): ApprovalMode | undefined {
|
|
112
|
+
return row.modes.find((mode) => mode === value);
|
|
113
|
+
}
|
|
@@ -152,6 +152,8 @@ export interface AssistantStatus {
|
|
|
152
152
|
version?: string;
|
|
153
153
|
lastError?: string;
|
|
154
154
|
checkpointsAvailable: boolean;
|
|
155
|
+
/** The module's configuration turns the sidecar off. */
|
|
156
|
+
disabled?: boolean;
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
/** One fact of a change set, a row of a DmsKeyValueList. */
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
"name": "Assistant settings",
|
|
53
53
|
"description": "AI and Builder defaults"
|
|
54
54
|
},
|
|
55
|
+
"guard_rails": {
|
|
56
|
+
"name": "Guard rails",
|
|
57
|
+
"description": "Default approval modes, Safe mode, what always asks and machine-local skills"
|
|
58
|
+
},
|
|
55
59
|
"usage": {
|
|
56
60
|
"name": "Usage",
|
|
57
61
|
"description": "Tokens the conversations used",
|
|
@@ -232,7 +236,7 @@
|
|
|
232
236
|
"sections": {
|
|
233
237
|
"ai": {
|
|
234
238
|
"label": "AI",
|
|
235
|
-
"description": "Which agent answers
|
|
239
|
+
"description": "Which agent answers and how it thinks."
|
|
236
240
|
},
|
|
237
241
|
"builder": {
|
|
238
242
|
"label": "Builder",
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
"name": "Réglages de l'assistant",
|
|
53
53
|
"description": "Valeurs par défaut de l'IA et du Builder"
|
|
54
54
|
},
|
|
55
|
+
"guard_rails": {
|
|
56
|
+
"name": "Garde-fous",
|
|
57
|
+
"description": "Modes d'approbation par défaut, mode sûr, demandes systématiques et skills de la machine"
|
|
58
|
+
},
|
|
55
59
|
"usage": {
|
|
56
60
|
"name": "Consommation",
|
|
57
61
|
"description": "Les tokens utilisés par les conversations",
|
|
@@ -232,7 +236,7 @@
|
|
|
232
236
|
"sections": {
|
|
233
237
|
"ai": {
|
|
234
238
|
"label": "IA",
|
|
235
|
-
"description": "Quel agent répond
|
|
239
|
+
"description": "Quel agent répond et comment il réfléchit."
|
|
236
240
|
},
|
|
237
241
|
"builder": {
|
|
238
242
|
"label": "Builder",
|
|
@@ -104,6 +104,11 @@
|
|
|
104
104
|
"collapse": "Collapse {path}",
|
|
105
105
|
"expand": "Expand {path}"
|
|
106
106
|
},
|
|
107
|
+
"guard_rails": {
|
|
108
|
+
"title": "Guard rails",
|
|
109
|
+
"description": "What the agent may do without asking you. Each change saves as you make it.",
|
|
110
|
+
"not_saved": "Not saved. The setting is unchanged."
|
|
111
|
+
},
|
|
107
112
|
"toast": {
|
|
108
113
|
"undone": "Undone · checkpoint #{number} restored",
|
|
109
114
|
"undone_description": "The page reloads with the files as they were. | {count} change sets were undone; the page reloads with the files as they were.",
|
|
@@ -104,6 +104,11 @@
|
|
|
104
104
|
"collapse": "Replier {path}",
|
|
105
105
|
"expand": "Déplier {path}"
|
|
106
106
|
},
|
|
107
|
+
"guard_rails": {
|
|
108
|
+
"title": "Garde-fous",
|
|
109
|
+
"description": "Ce que l'agent peut faire sans vous demander. Chaque changement s'enregistre dès que vous le faites.",
|
|
110
|
+
"not_saved": "Non enregistré. Le réglage n'a pas changé."
|
|
111
|
+
},
|
|
107
112
|
"toast": {
|
|
108
113
|
"undone": "Annulé · point de restauration #{number} restauré",
|
|
109
114
|
"undone_description": "La page se recharge avec les fichiers tels qu'ils étaient. | {count} lots ont été annulés ; la page se recharge avec les fichiers tels qu'ils étaient.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms-assistant",
|
|
3
|
-
"version": "0.2.8-next.
|
|
3
|
+
"version": "0.2.8-next.452.gae7538c",
|
|
4
4
|
"description": "Development assistant for the AntelopeJS DMS: a chat panel and coding agent that edit the project in reviewable, undoable change sets, and an onboarding that starts a project from scratch or from a database you already run.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
"dmsFrontend": "dist/frontend-module.js",
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "ae7538c2739fd9b0312fa919964b02b21060e503",
|
|
103
103
|
"scripts": {
|
|
104
104
|
"build": "rimraf dist && tsc",
|
|
105
105
|
"build:sidecar": "pnpm --dir sidecar run build",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/constants/timing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/constants/timing.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAM1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAQ5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAO7C,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC"}
|