@caplets/core 0.18.4 → 0.18.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/dist/index.js +1 -1
- package/dist/native/process-cleanup.d.ts +4 -1
- package/dist/native.d.ts +1 -1
- package/dist/native.js +21 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1320,7 +1320,7 @@ const EMPTY_COMPLETION_RESULT = { completion: {
|
|
|
1320
1320
|
} };
|
|
1321
1321
|
//#endregion
|
|
1322
1322
|
//#region package.json
|
|
1323
|
-
var version = "0.18.
|
|
1323
|
+
var version = "0.18.5";
|
|
1324
1324
|
//#endregion
|
|
1325
1325
|
//#region src/serve/session.ts
|
|
1326
1326
|
var CapletsMcpSession = class {
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { NativeCapletsService } from "./service";
|
|
2
|
-
export
|
|
2
|
+
export type NativeCapletsProcessCleanupOptions = {
|
|
3
|
+
writeErr?: (message: string) => void;
|
|
4
|
+
};
|
|
5
|
+
export declare function registerNativeCapletsProcessCleanup(service: NativeCapletsService, options?: NativeCapletsProcessCleanupOptions): void;
|
package/dist/native.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createNativeCapletsService, type NativeCapletTool, type NativeCapletsService, type NativeCapletsServiceOptions, type NativeCapletsToolsChangedListener, } from "./native/service";
|
|
2
|
-
export { registerNativeCapletsProcessCleanup } from "./native/process-cleanup";
|
|
2
|
+
export { registerNativeCapletsProcessCleanup, type NativeCapletsProcessCleanupOptions, } from "./native/process-cleanup";
|
|
3
3
|
export { nativeCapletPromptGuidance, nativeCapletToolDescription, nativeCapletToolName, nativeCapletsSystemGuidance, } from "./native/tools";
|
|
4
4
|
export { generatedToolInputSchema } from "./tools";
|
|
5
5
|
export { generatedToolInputJsonSchema } from "./generated-tool-input-schema";
|
package/dist/native.js
CHANGED
|
@@ -155,10 +155,10 @@ var RemoteNativeCapletsService = class {
|
|
|
155
155
|
await this.reloadFromClient();
|
|
156
156
|
return !this.closed;
|
|
157
157
|
} catch (retryError) {
|
|
158
|
-
this.warn(`Could not reload remote Caplets tools: ${errorMessage$
|
|
158
|
+
this.warn(`Could not reload remote Caplets tools: ${errorMessage$2(retryError)}\n`);
|
|
159
159
|
return false;
|
|
160
160
|
}
|
|
161
|
-
this.warn(`Could not reload remote Caplets tools: ${errorMessage$
|
|
161
|
+
this.warn(`Could not reload remote Caplets tools: ${errorMessage$2(error)}\n`);
|
|
162
162
|
return false;
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -213,11 +213,7 @@ var RemoteNativeCapletsService = class {
|
|
|
213
213
|
for (const listener of this.listeners) listener(tools);
|
|
214
214
|
}
|
|
215
215
|
warn(message) {
|
|
216
|
-
|
|
217
|
-
this.options.writeErr(message);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
process.stderr.write(message);
|
|
216
|
+
this.options.writeErr?.(message);
|
|
221
217
|
}
|
|
222
218
|
};
|
|
223
219
|
function remoteToolToNativeTool(tool) {
|
|
@@ -248,14 +244,14 @@ function operationNamesFromSchema(schema) {
|
|
|
248
244
|
function isPlainObject(value) {
|
|
249
245
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
250
246
|
}
|
|
251
|
-
function errorMessage$
|
|
247
|
+
function errorMessage$2(error) {
|
|
252
248
|
return error instanceof Error ? error.message : String(error);
|
|
253
249
|
}
|
|
254
250
|
function remoteAuthError() {
|
|
255
251
|
return new CapletsError("AUTH_FAILED", "Remote Caplets authentication failed; check CAPLETS_SERVER_USER and CAPLETS_SERVER_PASSWORD.");
|
|
256
252
|
}
|
|
257
253
|
function isSessionFailure(error) {
|
|
258
|
-
const message = errorMessage$
|
|
254
|
+
const message = errorMessage$2(error).toLowerCase();
|
|
259
255
|
return /session|transport|connection|connect|closed|invalid/u.test(message);
|
|
260
256
|
}
|
|
261
257
|
function isAuthFailure(error) {
|
|
@@ -264,7 +260,7 @@ function isAuthFailure(error) {
|
|
|
264
260
|
const statusCode = typeof candidate?.statusCode === "number" ? candidate.statusCode : void 0;
|
|
265
261
|
const code = typeof candidate?.code === "number" ? candidate.code : void 0;
|
|
266
262
|
if (status === 401 || status === 403 || statusCode === 401 || statusCode === 403 || code === 401 || code === 403) return true;
|
|
267
|
-
return /\b(401|403|unauthorized|forbidden)\b/iu.test(errorMessage$
|
|
263
|
+
return /\b(401|403|unauthorized|forbidden)\b/iu.test(errorMessage$2(error));
|
|
268
264
|
}
|
|
269
265
|
//#endregion
|
|
270
266
|
//#region src/native/service.ts
|
|
@@ -286,7 +282,7 @@ function createNativeCapletsService(options = {}) {
|
|
|
286
282
|
}), local, options);
|
|
287
283
|
} catch (error) {
|
|
288
284
|
local.close().catch((closeError) => {
|
|
289
|
-
writeErr(options, `Could not close local overlay Caplets service: ${errorMessage(closeError)}\n`);
|
|
285
|
+
writeErr(options, `Could not close local overlay Caplets service: ${errorMessage$1(closeError)}\n`);
|
|
290
286
|
});
|
|
291
287
|
throw error;
|
|
292
288
|
}
|
|
@@ -296,7 +292,10 @@ function createNativeCapletsService(options = {}) {
|
|
|
296
292
|
var DefaultNativeCapletsService = class {
|
|
297
293
|
engine;
|
|
298
294
|
constructor(options) {
|
|
299
|
-
this.engine = new CapletsEngine(
|
|
295
|
+
this.engine = new CapletsEngine({
|
|
296
|
+
...options,
|
|
297
|
+
writeErr: options.writeErr ?? (() => void 0)
|
|
298
|
+
});
|
|
300
299
|
}
|
|
301
300
|
listTools() {
|
|
302
301
|
return this.engine.enabledServers().map((caplet) => {
|
|
@@ -381,7 +380,7 @@ var CompositeNativeCapletsService = class {
|
|
|
381
380
|
for (const listener of this.listeners) try {
|
|
382
381
|
listener(this.listTools());
|
|
383
382
|
} catch (error) {
|
|
384
|
-
writeErr(this.options, `Caplets tools-changed listener failed: ${errorMessage(error)}\n`);
|
|
383
|
+
writeErr(this.options, `Caplets tools-changed listener failed: ${errorMessage$1(error)}\n`);
|
|
385
384
|
}
|
|
386
385
|
}
|
|
387
386
|
mergeTools() {
|
|
@@ -393,7 +392,7 @@ var CompositeNativeCapletsService = class {
|
|
|
393
392
|
try {
|
|
394
393
|
return await service.reload();
|
|
395
394
|
} catch (error) {
|
|
396
|
-
writeErr(this.options, `Could not reload composite Caplets tools from ${label}: ${errorMessage(error)}\n`);
|
|
395
|
+
writeErr(this.options, `Could not reload composite Caplets tools from ${label}: ${errorMessage$1(error)}\n`);
|
|
397
396
|
return;
|
|
398
397
|
}
|
|
399
398
|
}
|
|
@@ -406,7 +405,7 @@ function createLocalOverlayConfigLoader(options) {
|
|
|
406
405
|
try {
|
|
407
406
|
result = loadLocalOverlayConfigWithSources(configPath, projectConfigPath);
|
|
408
407
|
} catch (error) {
|
|
409
|
-
writeErr(options, `Caplets local overlay warning: Could not load local overlay config: ${errorMessage(error)}\n`);
|
|
408
|
+
writeErr(options, `Caplets local overlay warning: Could not load local overlay config: ${errorMessage$1(error)}\n`);
|
|
410
409
|
if (hasLoaded) throw new CapletsError("CONFIG_INVALID", "Caplets local overlay reload failed; keeping last known-good config.", error);
|
|
411
410
|
hasLoaded = true;
|
|
412
411
|
return parseConfig({});
|
|
@@ -423,14 +422,14 @@ function warningKey(warning) {
|
|
|
423
422
|
return `${warning.kind}\0${warning.path}\0${warning.message}`;
|
|
424
423
|
}
|
|
425
424
|
function writeErr(options, message) {
|
|
426
|
-
|
|
425
|
+
options.writeErr?.(message);
|
|
427
426
|
}
|
|
428
|
-
function errorMessage(error) {
|
|
427
|
+
function errorMessage$1(error) {
|
|
429
428
|
return error instanceof Error ? error.message : String(error);
|
|
430
429
|
}
|
|
431
430
|
//#endregion
|
|
432
431
|
//#region src/native/process-cleanup.ts
|
|
433
|
-
function registerNativeCapletsProcessCleanup(service) {
|
|
432
|
+
function registerNativeCapletsProcessCleanup(service, options = {}) {
|
|
434
433
|
let closed = false;
|
|
435
434
|
const close = async () => {
|
|
436
435
|
if (closed) return;
|
|
@@ -438,7 +437,7 @@ function registerNativeCapletsProcessCleanup(service) {
|
|
|
438
437
|
try {
|
|
439
438
|
await service.close();
|
|
440
439
|
} catch (error) {
|
|
441
|
-
|
|
440
|
+
options.writeErr?.(`Failed to close Caplets service: ${errorMessage(error)}\n`);
|
|
442
441
|
process.exitCode = 1;
|
|
443
442
|
}
|
|
444
443
|
};
|
|
@@ -454,5 +453,8 @@ function registerNativeCapletsProcessCleanup(service) {
|
|
|
454
453
|
process.once("SIGINT", closeAndExit);
|
|
455
454
|
process.once("SIGTERM", closeAndExit);
|
|
456
455
|
}
|
|
456
|
+
function errorMessage(error) {
|
|
457
|
+
return error instanceof Error ? error.message : String(error);
|
|
458
|
+
}
|
|
457
459
|
//#endregion
|
|
458
460
|
export { RemoteNativeCapletsService, createNativeCapletsService, createSdkRemoteCapletsClient, generatedToolInputJsonSchema, generatedToolInputSchema, nativeCapletPromptGuidance, nativeCapletToolDescription, nativeCapletToolName, nativeCapletsSystemGuidance, registerNativeCapletsProcessCleanup, resolveNativeCapletsServiceOptions };
|