arcane-os 0.40.1 → 0.42.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.
@@ -11,7 +11,8 @@ const TOOL_NAME_PATTERN=/^[a-z][a-z0-9_]*$/;
11
11
  const REPORT_FIELDS=new Set([
12
12
  'message',
13
13
  'final_message',
14
- 'remembered_actions'
14
+ 'remembered_actions',
15
+ 'responseToUsersPromptComplete'
15
16
  ]);
16
17
 
17
18
  function invalid(message){
@@ -88,11 +89,14 @@ function completeValue(value){
88
89
  /**
89
90
  * Creates a provider-neutral terminal tool for one user-facing conversation
90
91
  * closeout. The tool performs no inference, persistence, rendering, task
91
- * execution, navigation, or external delivery.
92
+ * execution, navigation, or external delivery. An optional
93
+ * responseToUsersPromptComplete declaration adds app-owned completion metadata;
94
+ * its description is required and its required setting defaults to false.
92
95
  */
93
96
  export function createConversationClosingReportTool({
94
97
  name=DEFAULT_TOOL_NAME,
95
- description='Prepare a complete closing report when the user clearly ends a conversation.'
98
+ description='Prepare a complete closing report when the user clearly ends a conversation.',
99
+ responseToUsersPromptComplete
96
100
  }={}){
97
101
  if(!is.string(name)||!TOOL_NAME_PATTERN.test(name)){
98
102
  throw invalid('The closing-report tool name is invalid.');
@@ -101,7 +105,7 @@ export function createConversationClosingReportTool({
101
105
  throw invalid('The closing-report tool description is invalid.');
102
106
  }
103
107
 
104
- return completeValue({
108
+ const tool={
105
109
  type:'function',
106
110
  function:{
107
111
  name,
@@ -145,7 +149,33 @@ export function createConversationClosingReportTool({
145
149
  required:['message','final_message']
146
150
  }
147
151
  }
148
- });
152
+ };
153
+
154
+ if(responseToUsersPromptComplete!==undefined){
155
+ if(!isPlainRecord(responseToUsersPromptComplete)){
156
+ throw invalid('responseToUsersPromptComplete options must be an object.');
157
+ }
158
+ const {
159
+ required=false,
160
+ description:completionDescription
161
+ }=responseToUsersPromptComplete;
162
+ if(!is.boolean(required)){
163
+ throw invalid('responseToUsersPromptComplete.required must be a boolean.');
164
+ }
165
+ tool.function.parameters.properties.responseToUsersPromptComplete={
166
+ type:'boolean',
167
+ description:normalizedText(
168
+ completionDescription,
169
+ 'responseToUsersPromptComplete.description',
170
+ {required:true}
171
+ )
172
+ };
173
+ if(required){
174
+ tool.function.parameters.required.push('responseToUsersPromptComplete');
175
+ }
176
+ }
177
+
178
+ return completeValue(tool);
149
179
  }
150
180
 
151
181
  /**
@@ -181,13 +211,22 @@ export function normalizeConversationClosingReport(value){
181
211
  throw invalid(`Unexpected closing-report field: ${unexpectedField}.`);
182
212
  }
183
213
 
184
- return completeValue({
214
+ const report={
185
215
  message:normalizedText(source.message,'message',{required:true}),
186
216
  finalMessage:normalizedFinalMessage(source.final_message),
187
217
  rememberedActions:normalizeRememberedConversationActions(
188
218
  source.remembered_actions||[]
189
219
  )
190
- });
220
+ };
221
+
222
+ if(Object.hasOwn(source,'responseToUsersPromptComplete')){
223
+ if(!is.boolean(source.responseToUsersPromptComplete)){
224
+ throw invalid('responseToUsersPromptComplete must be a boolean.');
225
+ }
226
+ report.responseToUsersPromptComplete=source.responseToUsersPromptComplete;
227
+ }
228
+
229
+ return completeValue(report);
191
230
  }
192
231
 
193
232
  /**
@@ -233,13 +272,17 @@ export function classifyConversationClosingReportCalls(calls={}, {
233
272
  }
234
273
 
235
274
  export function formatConversationClosingReport(value){
236
- const normalizedInput=isPlainRecord(value)&&value.finalMessage!==undefined
237
- ?{
275
+ let normalizedInput=value;
276
+ if(isPlainRecord(value)&&value.finalMessage!==undefined){
277
+ normalizedInput={
238
278
  message:value.message,
239
279
  final_message:value.finalMessage,
240
280
  remembered_actions:value.rememberedActions,
281
+ };
282
+ if(Object.hasOwn(value,'responseToUsersPromptComplete')){
283
+ normalizedInput.responseToUsersPromptComplete=value.responseToUsersPromptComplete;
241
284
  }
242
- :value;
285
+ }
243
286
  return formatConversationClosingReportText(
244
287
  normalizeConversationClosingReport(normalizedInput).finalMessage
245
288
  );