arcane-os 0.1.0-dev.5
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/CHANGELOG.md +154 -0
- package/COMMERCIAL-LICENSE.md +13 -0
- package/LICENSE +661 -0
- package/NOTICE +70 -0
- package/README.md +448 -0
- package/bin/arcane-test.mjs +741 -0
- package/bin/arcane.mjs +5 -0
- package/docs/architecture.md +234 -0
- package/docs/compatibility.md +36 -0
- package/docs/event-manager.md +166 -0
- package/docs/platform-targets.md +108 -0
- package/docs/publishing.md +203 -0
- package/docs/reference/README.md +117 -0
- package/docs/reference/arcane-ollama.md +288 -0
- package/docs/reference/availability-and-normalization.md +123 -0
- package/docs/reference/behavioral-testing.md +86 -0
- package/docs/reference/cli.md +569 -0
- package/docs/reference/core/README.md +62 -0
- package/docs/reference/core/arcane-ai-contracts.md +873 -0
- package/docs/reference/core/arcane-api.md +601 -0
- package/docs/reference/core/arcane-entities.md +65 -0
- package/docs/reference/core/arcane-events.md +134 -0
- package/docs/reference/core/ollama-module.md +181 -0
- package/docs/reference/core/reference/arcane-api/ai-and-ollama.md +1909 -0
- package/docs/reference/core/reference/arcane-api/applications-terminal-capabilities.md +1057 -0
- package/docs/reference/core/reference/arcane-api/core-and-events.md +320 -0
- package/docs/reference/core/reference/arcane-api/filesystem-storage-preferences-appearance.md +610 -0
- package/docs/reference/core/reference/arcane-api/namespaces.md +1157 -0
- package/docs/reference/core/reference/arcane-api/platform-installation-users-system.md +1423 -0
- package/docs/reference/core/reference/arcane-api/session-provisioning-diagnostics-development.md +315 -0
- package/docs/reference/event-manager.md +957 -0
- package/docs/reference/inventory/package-api.json +2632 -0
- package/docs/reference/inventory/runtime-components.json +934 -0
- package/docs/reference/inventory/runtime-entities.json +26 -0
- package/docs/reference/inventory/runtime-modules.json +1249 -0
- package/docs/reference/protocols.md +242 -0
- package/docs/reference/runtime-components.md +1098 -0
- package/docs/reference/runtime-entities.md +303 -0
- package/docs/reference/runtime-modules.md +2010 -0
- package/docs/reference/sdk-api.md +4901 -0
- package/docs/roadmap.md +79 -0
- package/docs/work-amplification.md +124 -0
- package/node_modules/event-pubsub/CHANGELOG.md +55 -0
- package/node_modules/event-pubsub/MIGRATION.md +70 -0
- package/node_modules/event-pubsub/README.md +363 -0
- package/node_modules/event-pubsub/SECURITY.md +37 -0
- package/node_modules/event-pubsub/index.js +141 -0
- package/node_modules/event-pubsub/licence +21 -0
- package/node_modules/event-pubsub/package.json +59 -0
- package/node_modules/strong-type/README.md +408 -0
- package/node_modules/strong-type/assets/strong-type-header.png +0 -0
- package/node_modules/strong-type/index.js +1151 -0
- package/node_modules/strong-type/licence +21 -0
- package/node_modules/strong-type/node.js +125 -0
- package/node_modules/strong-type/package.json +61 -0
- package/package.json +95 -0
- package/runtime/ARCANE_RUNTIME_RELEASE.json +791 -0
- package/runtime/arcane/components/app-bar.html +468 -0
- package/runtime/arcane/components/assistant-panel.html +715 -0
- package/runtime/arcane/components/calculator.html +8 -0
- package/runtime/arcane/components/chart.html +655 -0
- package/runtime/arcane/components/chat.html +1225 -0
- package/runtime/arcane/components/conversation-view.html +13 -0
- package/runtime/arcane/components/dashboard-config.html +341 -0
- package/runtime/arcane/components/data-maintenance.html +112 -0
- package/runtime/arcane/components/data-view.html +92 -0
- package/runtime/arcane/components/directory-picker.html +197 -0
- package/runtime/arcane/components/document-inspector.html +252 -0
- package/runtime/arcane/components/file-drop.html +264 -0
- package/runtime/arcane/components/file-inspector.html +293 -0
- package/runtime/arcane/components/file-manager.html +1715 -0
- package/runtime/arcane/components/header.html +142 -0
- package/runtime/arcane/components/integration-settings.html +14 -0
- package/runtime/arcane/components/local-ai-status.html +360 -0
- package/runtime/arcane/components/markdown-document.html +1048 -0
- package/runtime/arcane/components/markdown-editor.html +360 -0
- package/runtime/arcane/components/media-embed.html +8 -0
- package/runtime/arcane/components/modal.html +402 -0
- package/runtime/arcane/components/output-panel.html +259 -0
- package/runtime/arcane/components/preferences-form.html +135 -0
- package/runtime/arcane/components/record-timeline.html +105 -0
- package/runtime/arcane/components/relationship-board.html +116 -0
- package/runtime/arcane/components/screen-capture.html +8 -0
- package/runtime/arcane/components/source-code-viewer.html +441 -0
- package/runtime/arcane/components/source-explanation.html +124 -0
- package/runtime/arcane/components/speech.html +365 -0
- package/runtime/arcane/components/summary-strip.html +177 -0
- package/runtime/arcane/components/table.html +77 -0
- package/runtime/arcane/components/task-progress.html +282 -0
- package/runtime/arcane/components/terminal-workspace.html +65 -0
- package/runtime/arcane/components/theme-editor.html +41 -0
- package/runtime/arcane/components/theme-switcher.html +46 -0
- package/runtime/arcane/components/unified-inbox.html +20 -0
- package/runtime/arcane/components/voice-transcription.html +476 -0
- package/runtime/arcane/components/weather-widget.html +8 -0
- package/runtime/arcane/components/web-navigator.html +239 -0
- package/runtime/arcane/css/communications.css +1 -0
- package/runtime/arcane/css/dashboard-config.css +45 -0
- package/runtime/arcane/css/document-site.css +981 -0
- package/runtime/arcane/css/layout.css +438 -0
- package/runtime/arcane/css/primitives.css +321 -0
- package/runtime/arcane/css/theme.css +112 -0
- package/runtime/arcane/css/utility-workspace.css +1 -0
- package/runtime/arcane/entities/ApiModelRecord.js +20 -0
- package/runtime/arcane/entities/Calculation.js +13 -0
- package/runtime/arcane/entities/Chat.js +581 -0
- package/runtime/arcane/entities/CommunicationMessage.js +29 -0
- package/runtime/arcane/entities/CommunicationThread.js +21 -0
- package/runtime/arcane/entities/Document.js +10 -0
- package/runtime/arcane/entities/File.js +143 -0
- package/runtime/arcane/entities/Image.js +135 -0
- package/runtime/arcane/entities/IntentEnvelope.js +834 -0
- package/runtime/arcane/entities/Preference.js +83 -0
- package/runtime/arcane/entities/TWiNPolicyDecision.js +1092 -0
- package/runtime/arcane/entities/TerminalSession.js +46 -0
- package/runtime/arcane/entities/Theme.js +107 -0
- package/runtime/arcane/entities/User.js +1046 -0
- package/runtime/arcane/entities/Weather.js +23 -0
- package/runtime/arcane/img/arcane-os-everywhere.png +0 -0
- package/runtime/arcane/img/arrow-left.png +0 -0
- package/runtime/arcane/img/arrow-right.png +0 -0
- package/runtime/arcane/img/doc.svg +5 -0
- package/runtime/arcane/img/folder.svg +4 -0
- package/runtime/arcane/img/image.svg +5 -0
- package/runtime/arcane/img/refresh.png +0 -0
- package/runtime/arcane/img/send.svg +9 -0
- package/runtime/arcane/img/trash.svg +5 -0
- package/runtime/arcane/img/upload.svg +5 -0
- package/runtime/arcane/modules/AI.js +2048 -0
- package/runtime/arcane/modules/AIPreferenceRuntime.js +32 -0
- package/runtime/arcane/modules/AIPreferenceTuple.js +92 -0
- package/runtime/arcane/modules/AIResponseLength.js +42 -0
- package/runtime/arcane/modules/AIResponseURLPolicy.js +626 -0
- package/runtime/arcane/modules/AnsiText.js +53 -0
- package/runtime/arcane/modules/ApiModelDatabase.js +25 -0
- package/runtime/arcane/modules/AppDataScope.js +245 -0
- package/runtime/arcane/modules/AppearancePreferences.js +28 -0
- package/runtime/arcane/modules/ArcaneCommunicationBridge.js +22 -0
- package/runtime/arcane/modules/ArcaneNavigationPolicy.js +135 -0
- package/runtime/arcane/modules/ArcaneNetworkPolicy.js +255 -0
- package/runtime/arcane/modules/AsyncBoundary.js +161 -0
- package/runtime/arcane/modules/BrowserTestSuite.js +326 -0
- package/runtime/arcane/modules/CalculatorEngine.js +20 -0
- package/runtime/arcane/modules/CaseEvidenceIndexer.js +134 -0
- package/runtime/arcane/modules/ChartLibrary.js +35 -0
- package/runtime/arcane/modules/ChatRecords.js +13 -0
- package/runtime/arcane/modules/CommunicationAppController.js +43 -0
- package/runtime/arcane/modules/CommunicationHub.js +16 -0
- package/runtime/arcane/modules/CommunicationPreferences.js +13 -0
- package/runtime/arcane/modules/CommunicationProviderRegistry.js +16 -0
- package/runtime/arcane/modules/ComponentContracts.js +586 -0
- package/runtime/arcane/modules/ConfiguredAIChatSession.js +288 -0
- package/runtime/arcane/modules/ConversationActionItems.js +488 -0
- package/runtime/arcane/modules/ConversationClosingReport.js +274 -0
- package/runtime/arcane/modules/ConversationTimebox.js +527 -0
- package/runtime/arcane/modules/CoreLocalModelCatalog.js +255 -0
- package/runtime/arcane/modules/DBLS.js +171 -0
- package/runtime/arcane/modules/DBOPFS.js +1154 -0
- package/runtime/arcane/modules/DBOPFSWorker.js +116 -0
- package/runtime/arcane/modules/DataMaintenance.js +91 -0
- package/runtime/arcane/modules/DevelopmentWorkspace.js +74 -0
- package/runtime/arcane/modules/DirectoryPicker.js +109 -0
- package/runtime/arcane/modules/DocumentNavigation.js +223 -0
- package/runtime/arcane/modules/Errors.js +1025 -0
- package/runtime/arcane/modules/GifEncoder.js +29 -0
- package/runtime/arcane/modules/HTMLImport.js +114 -0
- package/runtime/arcane/modules/InMemoryCommunicationProvider.js +14 -0
- package/runtime/arcane/modules/IsolatedModelQuestionRunner.js +275 -0
- package/runtime/arcane/modules/LocalAIReadiness.js +870 -0
- package/runtime/arcane/modules/LocalAIReadinessController.js +156 -0
- package/runtime/arcane/modules/MD.js +111 -0
- package/runtime/arcane/modules/Mail.js +352 -0
- package/runtime/arcane/modules/MailTransport.mjs +180 -0
- package/runtime/arcane/modules/Marked.min.js +71 -0
- package/runtime/arcane/modules/MemoryRecords.js +44 -0
- package/runtime/arcane/modules/MessageAdvisory.js +38 -0
- package/runtime/arcane/modules/ModelDefinition.js +189 -0
- package/runtime/arcane/modules/Ollama.js +74 -0
- package/runtime/arcane/modules/OllamaModelIdentifier.js +21 -0
- package/runtime/arcane/modules/OllamaSettings.js +24 -0
- package/runtime/arcane/modules/OpenMeteoWeatherProvider.js +14 -0
- package/runtime/arcane/modules/PreferenceStore.js +109 -0
- package/runtime/arcane/modules/QRCode.min.js +1 -0
- package/runtime/arcane/modules/Questionnaire.js +61 -0
- package/runtime/arcane/modules/RecordLinkIndex.js +24 -0
- package/runtime/arcane/modules/RecordPassageIndex.js +222 -0
- package/runtime/arcane/modules/RecordReviewStore.js +94 -0
- package/runtime/arcane/modules/RevocableProjectionLedger.js +1623 -0
- package/runtime/arcane/modules/RiskSignalAnalyzer.js +37 -0
- package/runtime/arcane/modules/ScamRiskPolicy.js +62 -0
- package/runtime/arcane/modules/ScopedOPFSCache.js +183 -0
- package/runtime/arcane/modules/ScreenCapture.js +20 -0
- package/runtime/arcane/modules/SpeechPlayback.js +581 -0
- package/runtime/arcane/modules/StaticDocumentCatalog.js +1248 -0
- package/runtime/arcane/modules/SystemAppearance.js +20 -0
- package/runtime/arcane/modules/SystemPlatformPresentation.js +51 -0
- package/runtime/arcane/modules/SystemToolRegistry.js +28 -0
- package/runtime/arcane/modules/TerminalClient.js +52 -0
- package/runtime/arcane/modules/TerminalCommandRegistry.js +50 -0
- package/runtime/arcane/modules/ThemeBootstrap.js +26 -0
- package/runtime/arcane/modules/ThemeManager.js +131 -0
- package/runtime/arcane/modules/TimeGuard.js +149 -0
- package/runtime/arcane/modules/ToolCallRouter.js +83 -0
- package/runtime/arcane/modules/WaitForComponent.js +102 -0
- package/runtime/arcane/modules/YouTubeMedia.js +16 -0
- package/runtime/arcane/modules/uPlot.LICENSE.txt +21 -0
- package/runtime/arcane/modules/uPlot.iife.min.js +2 -0
- package/runtime/arcane/modules/uPlot.min.css +1 -0
- package/runtime/arcane/security/arcane-network-policy.json +6 -0
- package/runtime/strong-type/index.js +352 -0
- package/runtime/strong-type/licence +21 -0
- package/runtime/strong-type/package.json +45 -0
- package/schemas/arcane-app-bundle.schema.json +125 -0
- package/schemas/arcane-app.schema.json +329 -0
- package/schemas/arcane-lock.schema.json +86 -0
- package/schemas/arcane-package.schema.json +224 -0
- package/schemas/cli-event.schema.json +122 -0
- package/schemas/event-stack.schema.json +152 -0
- package/schemas/native-build-plan.schema.json +176 -0
- package/schemas/target-adapter.schema.json +117 -0
- package/src/app-descriptor.mjs +500 -0
- package/src/cli/main.mjs +561 -0
- package/src/constants.mjs +31 -0
- package/src/dev-server.mjs +718 -0
- package/src/doctor.mjs +315 -0
- package/src/dom-event-instrumentation.mjs +594 -0
- package/src/errors.mjs +75 -0
- package/src/event-manager.mjs +1342 -0
- package/src/event-queue.mjs +138 -0
- package/src/events.mjs +219 -0
- package/src/index.mjs +177 -0
- package/src/integrated-provider-loader.mjs +432 -0
- package/src/native-plan.mjs +698 -0
- package/src/native-provider-loader.mjs +1126 -0
- package/src/packager/core.mjs +2691 -0
- package/src/process.mjs +353 -0
- package/src/release-bundle.mjs +2523 -0
- package/src/repository.mjs +90 -0
- package/src/runtime.mjs +452 -0
- package/src/scaffold.mjs +380 -0
- package/src/targets/index.mjs +436 -0
- package/src/templates/assets/app-icon.png +0 -0
- package/src/templates/workspace-template.mjs +388 -0
- package/src/testing-loader.mjs +9 -0
- package/src/testing.mjs +427 -0
- package/src/toolchain.mjs +1335 -0
- package/src/update-check.mjs +307 -0
- package/src/workspace.mjs +449 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CONVERSATION_ACTION_ITEM_BASES,
|
|
3
|
+
MAX_CONVERSATION_ACTION_ITEM_CHARACTERS,
|
|
4
|
+
MAX_CONVERSATION_REMEMBERED_ACTIONS,
|
|
5
|
+
normalizeRememberedConversationActions
|
|
6
|
+
} from './ConversationActionItems.js?v=2';
|
|
7
|
+
|
|
8
|
+
const DEFAULT_TOOL_NAME='prepare_conversation_closing_report';
|
|
9
|
+
const TOOL_NAME_PATTERN=/^[a-z][a-z0-9_]{0,63}$/;
|
|
10
|
+
const MAX_ARGUMENT_CHARACTERS=16*1024;
|
|
11
|
+
const MAX_FINAL_MESSAGE_CHARACTERS=5000;
|
|
12
|
+
const REPORT_FIELDS=Object.freeze(new Set([
|
|
13
|
+
'final_message',
|
|
14
|
+
'remembered_actions'
|
|
15
|
+
]));
|
|
16
|
+
|
|
17
|
+
function invalid(message){
|
|
18
|
+
const error=new TypeError(message);
|
|
19
|
+
error.code='CONVERSATION_CLOSING_REPORT_INVALID';
|
|
20
|
+
return error;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isPlainRecord(value){
|
|
24
|
+
if(!value||typeof value!=='object'||Array.isArray(value)){
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const prototype=Object.getPrototypeOf(value);
|
|
29
|
+
return prototype===Object.prototype||prototype===null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function boundedText(value,label,maximum,{required=false}={}){
|
|
33
|
+
if(value===undefined||value===null||value===''){
|
|
34
|
+
if(required){
|
|
35
|
+
throw invalid(`${label} is required.`);
|
|
36
|
+
}
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
if(typeof value!=='string'){
|
|
40
|
+
throw invalid(`${label} must be a string.`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const normalized=value.replace(/[\u0000-\u001f\u007f]+/g,' ').replace(/\s+/g,' ').trim();
|
|
44
|
+
|
|
45
|
+
if(!normalized&&required){
|
|
46
|
+
throw invalid(`${label} is required.`);
|
|
47
|
+
}
|
|
48
|
+
if(normalized.length>maximum){
|
|
49
|
+
throw invalid(`${label} exceeds ${maximum} characters.`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return normalized;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function boundedFinalMessage(value){
|
|
56
|
+
if(typeof value!=='string'){
|
|
57
|
+
throw invalid('final_message must be a string.');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const normalized=value
|
|
61
|
+
.replace(/\r\n?/g,'\n')
|
|
62
|
+
.replace(/[\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f]+/g,' ')
|
|
63
|
+
.trim();
|
|
64
|
+
|
|
65
|
+
if(!normalized){
|
|
66
|
+
throw invalid('final_message is required.');
|
|
67
|
+
}
|
|
68
|
+
if(normalized.length>MAX_FINAL_MESSAGE_CHARACTERS){
|
|
69
|
+
throw invalid(
|
|
70
|
+
`final_message exceeds ${MAX_FINAL_MESSAGE_CHARACTERS} characters.`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return normalized;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function parseArguments(value){
|
|
78
|
+
if(typeof value==='string'){
|
|
79
|
+
if(!value||value.length>MAX_ARGUMENT_CHARACTERS){
|
|
80
|
+
throw invalid('The closing-report arguments exceed the allowed size.');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
try{
|
|
84
|
+
value=JSON.parse(value);
|
|
85
|
+
}catch{
|
|
86
|
+
throw invalid('The closing-report arguments must be valid JSON.');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if(!isPlainRecord(value)){
|
|
90
|
+
throw invalid('The closing-report arguments must be an object.');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function escapeRawHTML(value){
|
|
97
|
+
return value
|
|
98
|
+
.replaceAll('&','&')
|
|
99
|
+
.replaceAll('<','<')
|
|
100
|
+
.replaceAll('>','>');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function deepFreeze(value){
|
|
104
|
+
if(!value||typeof value!=='object'||Object.isFrozen(value)){
|
|
105
|
+
return value;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
for(const child of Object.values(value)){
|
|
109
|
+
deepFreeze(child);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return Object.freeze(value);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Creates a provider-neutral terminal tool for one user-facing conversation
|
|
117
|
+
* closeout. The tool performs no inference, persistence, rendering, task
|
|
118
|
+
* execution, navigation, or external delivery.
|
|
119
|
+
*/
|
|
120
|
+
export function createConversationClosingReportTool({
|
|
121
|
+
name=DEFAULT_TOOL_NAME,
|
|
122
|
+
description='Prepare a bounded closing report when the user clearly ends a conversation.'
|
|
123
|
+
}={}){
|
|
124
|
+
if(typeof name!=='string'||!TOOL_NAME_PATTERN.test(name)){
|
|
125
|
+
throw invalid('The closing-report tool name is invalid.');
|
|
126
|
+
}
|
|
127
|
+
if(typeof description!=='string'||!description.trim()||description.length>1000){
|
|
128
|
+
throw invalid('The closing-report tool description is invalid.');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return deepFreeze({
|
|
132
|
+
type:'function',
|
|
133
|
+
function:{
|
|
134
|
+
name,
|
|
135
|
+
description:description.trim(),
|
|
136
|
+
parameters:{
|
|
137
|
+
type:'object',
|
|
138
|
+
additionalProperties:false,
|
|
139
|
+
properties:{
|
|
140
|
+
final_message:{
|
|
141
|
+
type:'string',
|
|
142
|
+
minLength:1,
|
|
143
|
+
maxLength:MAX_FINAL_MESSAGE_CHARACTERS,
|
|
144
|
+
description:'The complete final response shown to the user to close the conversation. When useful and grounded in the conversation, include a concise summary of what was accomplished, concrete progress or takeaways, and optional next steps or homework. Omit any of those elements when they would be inappropriate, unsafe, unwanted, or unsupported. Present next steps as choices, never obligations. If remembered_actions are included, mention them only as agreed follow-ups and never claim they were saved. End with a calm, warm closing that does not pressure the user or create new obligations.'
|
|
145
|
+
},
|
|
146
|
+
remembered_actions:{
|
|
147
|
+
type:'array',
|
|
148
|
+
maxItems:MAX_CONVERSATION_REMEMBERED_ACTIONS,
|
|
149
|
+
items:{
|
|
150
|
+
type:'object',
|
|
151
|
+
additionalProperties:false,
|
|
152
|
+
properties:{
|
|
153
|
+
text:{
|
|
154
|
+
type:'string',
|
|
155
|
+
minLength:1,
|
|
156
|
+
maxLength:MAX_CONVERSATION_ACTION_ITEM_CHARACTERS,
|
|
157
|
+
description:'The follow-up the user explicitly agreed to carry into a later conversation.'
|
|
158
|
+
},
|
|
159
|
+
basis:{
|
|
160
|
+
type:'string',
|
|
161
|
+
enum:[...CONVERSATION_ACTION_ITEM_BASES],
|
|
162
|
+
description:'Use exactly "user_commitment" when the user explicitly committed to act. Use exactly "optional_homework" only when the user explicitly agreed to carry optional homework forward.'
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
required:['text','basis']
|
|
166
|
+
},
|
|
167
|
+
description:'Optional machine-readable follow-ups for local Profile persistence. Include only commitments or optional homework the user explicitly agreed to carry into a later conversation. Do not include ordinary suggestions from final_message.'
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
required:['final_message']
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Returns a system-prompt suffix for an app-provided terminal tool. The app
|
|
178
|
+
* owns the trigger, provider call, persistence, rendering, and recipient.
|
|
179
|
+
*/
|
|
180
|
+
export function conversationClosingReportInstruction({
|
|
181
|
+
enabled=true,
|
|
182
|
+
toolName=DEFAULT_TOOL_NAME,
|
|
183
|
+
completionTrigger='the user clearly says they are finished or explicitly asks to wrap up'
|
|
184
|
+
}={}){
|
|
185
|
+
if(enabled!==true){
|
|
186
|
+
return '';
|
|
187
|
+
}
|
|
188
|
+
if(typeof toolName!=='string'||!TOOL_NAME_PATTERN.test(toolName)){
|
|
189
|
+
throw invalid('The closing-report tool name is invalid.');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const trigger=boundedText(
|
|
193
|
+
completionTrigger,
|
|
194
|
+
'The conversation completion trigger',
|
|
195
|
+
1000,
|
|
196
|
+
{required:true}
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
return `## Conversation closeout\nWhen ${trigger}, call \`${toolName}\` as the sole tool call and do not also answer in prose. Do not call it after a routine answer, while requested work remains open, or merely because a response is long. Use only facts established in the conversation. Never diagnose, score, judge, or infer personal traits. Put the complete user-facing closeout in final_message. Populate remembered_actions only for a commitment or optional homework the user explicitly agreed to carry into a later conversation; never turn an ordinary suggestion into a saved obligation or claim it was saved. The application separately requests consent before saving a remembered action, displays final_message in the conversation, and reports the save result. The tool does not send anything elsewhere or perform any suggested action.`;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function normalizeConversationClosingReport(value){
|
|
203
|
+
const source=parseArguments(value);
|
|
204
|
+
const unexpectedField=Object.keys(source).find(field=>!REPORT_FIELDS.has(field));
|
|
205
|
+
|
|
206
|
+
if(unexpectedField){
|
|
207
|
+
throw invalid(`Unexpected closing-report field: ${unexpectedField}.`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return Object.freeze({
|
|
211
|
+
finalMessage:boundedFinalMessage(source.final_message),
|
|
212
|
+
rememberedActions:normalizeRememberedConversationActions(
|
|
213
|
+
source.remembered_actions||[]
|
|
214
|
+
)
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Accepts a closing report only when it is the sole tool call. A mixed call is
|
|
220
|
+
* never partially executed, so closing cannot silently accompany another
|
|
221
|
+
* action or external side effect.
|
|
222
|
+
*/
|
|
223
|
+
export function classifyConversationClosingReportCalls(calls={}, {
|
|
224
|
+
toolName=DEFAULT_TOOL_NAME
|
|
225
|
+
}={}){
|
|
226
|
+
if(typeof toolName!=='string'||!TOOL_NAME_PATTERN.test(toolName)){
|
|
227
|
+
throw invalid('The closing-report tool name is invalid.');
|
|
228
|
+
}
|
|
229
|
+
if(!isPlainRecord(calls)){
|
|
230
|
+
return Object.freeze({present:false,accepted:false,report:null,error:invalid('Tool calls must be an object.')});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const names=Object.keys(calls);
|
|
234
|
+
const present=Object.hasOwn(calls,toolName);
|
|
235
|
+
|
|
236
|
+
if(!present){
|
|
237
|
+
return Object.freeze({present:false,accepted:false,report:null,error:null});
|
|
238
|
+
}
|
|
239
|
+
if(names.length!==1){
|
|
240
|
+
return Object.freeze({
|
|
241
|
+
present:true,
|
|
242
|
+
accepted:false,
|
|
243
|
+
report:null,
|
|
244
|
+
error:invalid('A conversation closing report must be the sole tool call.')
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
try{
|
|
249
|
+
return Object.freeze({
|
|
250
|
+
present:true,
|
|
251
|
+
accepted:true,
|
|
252
|
+
report:normalizeConversationClosingReport(calls[toolName]),
|
|
253
|
+
error:null
|
|
254
|
+
});
|
|
255
|
+
}catch(error){
|
|
256
|
+
return Object.freeze({present:true,accepted:false,report:null,error});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function formatConversationClosingReport(value){
|
|
261
|
+
const normalizedInput=isPlainRecord(value)&&value.finalMessage!==undefined
|
|
262
|
+
?{
|
|
263
|
+
final_message:value.finalMessage,
|
|
264
|
+
remembered_actions:value.rememberedActions,
|
|
265
|
+
}
|
|
266
|
+
:value;
|
|
267
|
+
return escapeRawHTML(
|
|
268
|
+
normalizeConversationClosingReport(normalizedInput).finalMessage
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export {
|
|
273
|
+
DEFAULT_TOOL_NAME as CONVERSATION_CLOSING_REPORT_TOOL_NAME
|
|
274
|
+
};
|