@toolplex/client 0.1.24 → 0.1.25
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.
|
@@ -3,7 +3,8 @@ import Registry from "../registry.js";
|
|
|
3
3
|
const logger = FileLogger;
|
|
4
4
|
export async function handleSavePlaybook(params) {
|
|
5
5
|
const startTime = Date.now();
|
|
6
|
-
|
|
6
|
+
const isValidationOnly = params.validate_only === true;
|
|
7
|
+
await logger.info(`Handling save playbook request${isValidationOnly ? " (validation only)" : ""}`);
|
|
7
8
|
await logger.debug(`Playbook params: ${JSON.stringify(params)}`);
|
|
8
9
|
const apiService = Registry.getToolplexApiService();
|
|
9
10
|
const telemetryLogger = Registry.getTelemetryLogger();
|
|
@@ -19,19 +20,34 @@ export async function handleSavePlaybook(params) {
|
|
|
19
20
|
if (clientContext.permissions.enable_read_only_mode) {
|
|
20
21
|
throw new Error("Saving playbooks is disabled in read-only mode");
|
|
21
22
|
}
|
|
22
|
-
// Enforce playbook policy before saving
|
|
23
|
+
// Enforce playbook policy before saving (runs in both validation and actual save)
|
|
23
24
|
policyEnforcer.enforceSavePlaybookPolicy(params);
|
|
25
|
+
// If validation-only mode, return success without saving or logging telemetry
|
|
26
|
+
if (isValidationOnly) {
|
|
27
|
+
await logger.info("Playbook validation passed");
|
|
28
|
+
return {
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: JSON.stringify({ validation: "passed" }),
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
24
37
|
const { playbook_name, description, actions, domain, keywords, requirements, privacy, source_playbook_id, fork_reason, } = params;
|
|
25
38
|
const response = await apiService.createPlaybook(playbook_name, description, actions, domain, keywords, requirements, privacy, source_playbook_id, fork_reason);
|
|
26
39
|
await logger.info(`Playbook created successfully with ID: ${response.id}`);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
// Only log telemetry for actual saves (not validation-only calls)
|
|
41
|
+
if (!isValidationOnly) {
|
|
42
|
+
await telemetryLogger.log("client_save_playbook", {
|
|
43
|
+
success: true,
|
|
44
|
+
log_context: {
|
|
45
|
+
playbook_id: response.id,
|
|
46
|
+
source_playbook_id: source_playbook_id,
|
|
47
|
+
},
|
|
48
|
+
latency_ms: Date.now() - startTime,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
35
51
|
return {
|
|
36
52
|
content: [
|
|
37
53
|
{
|
|
@@ -45,12 +61,15 @@ export async function handleSavePlaybook(params) {
|
|
|
45
61
|
}
|
|
46
62
|
catch (error) {
|
|
47
63
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
48
|
-
await logger.error(`Failed to create playbook: ${errorMessage}`);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
await logger.error(`Failed to ${isValidationOnly ? "validate" : "create"} playbook: ${errorMessage}`);
|
|
65
|
+
// Only log telemetry for actual saves (not validation-only calls)
|
|
66
|
+
if (!isValidationOnly) {
|
|
67
|
+
await telemetryLogger.log("client_save_playbook", {
|
|
68
|
+
success: false,
|
|
69
|
+
pii_sanitized_error_message: errorMessage,
|
|
70
|
+
latency_ms: Date.now() - startTime,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
54
73
|
return {
|
|
55
74
|
isError: true,
|
|
56
75
|
content: [
|
|
@@ -316,6 +316,7 @@ export declare const SavePlaybookParamsSchema: z.ZodObject<{
|
|
|
316
316
|
privacy: z.ZodOptional<z.ZodEnum<["public", "private"]>>;
|
|
317
317
|
source_playbook_id: z.ZodOptional<z.ZodString>;
|
|
318
318
|
fork_reason: z.ZodOptional<z.ZodString>;
|
|
319
|
+
validate_only: z.ZodOptional<z.ZodBoolean>;
|
|
319
320
|
}, "strip", z.ZodTypeAny, {
|
|
320
321
|
description: string;
|
|
321
322
|
playbook_name: string;
|
|
@@ -333,6 +334,7 @@ export declare const SavePlaybookParamsSchema: z.ZodObject<{
|
|
|
333
334
|
privacy?: "public" | "private" | undefined;
|
|
334
335
|
source_playbook_id?: string | undefined;
|
|
335
336
|
fork_reason?: string | undefined;
|
|
337
|
+
validate_only?: boolean | undefined;
|
|
336
338
|
}, {
|
|
337
339
|
description: string;
|
|
338
340
|
playbook_name: string;
|
|
@@ -350,6 +352,7 @@ export declare const SavePlaybookParamsSchema: z.ZodObject<{
|
|
|
350
352
|
privacy?: "public" | "private" | undefined;
|
|
351
353
|
source_playbook_id?: string | undefined;
|
|
352
354
|
fork_reason?: string | undefined;
|
|
355
|
+
validate_only?: boolean | undefined;
|
|
353
356
|
}>;
|
|
354
357
|
export type SavePlaybookParams = z.infer<typeof SavePlaybookParamsSchema>;
|
|
355
358
|
export declare const LogPlaybookUsageParamsSchema: z.ZodObject<{
|
|
@@ -126,6 +126,9 @@ export const SavePlaybookParamsSchema = z.object({
|
|
|
126
126
|
privacy: z.enum(["public", "private"]).optional(),
|
|
127
127
|
source_playbook_id: z.string().optional(),
|
|
128
128
|
fork_reason: z.string().optional(),
|
|
129
|
+
// Internal parameter for validation-only mode (not exposed to agent in tool definition)
|
|
130
|
+
// Use coerce to handle both boolean and string "true"/"false" from different LLM clients
|
|
131
|
+
validate_only: z.coerce.boolean().optional(),
|
|
129
132
|
});
|
|
130
133
|
// --------------------
|
|
131
134
|
// LogPlaybookUsageParams
|
|
@@ -126,6 +126,9 @@ export const SavePlaybookParamsSchema = z.object({
|
|
|
126
126
|
privacy: z.enum(["public", "private"]).optional(),
|
|
127
127
|
source_playbook_id: z.string().optional(),
|
|
128
128
|
fork_reason: z.string().optional(),
|
|
129
|
+
// Internal parameter for validation-only mode (not exposed to agent in tool definition)
|
|
130
|
+
// Use coerce to handle both boolean and string "true"/"false" from different LLM clients
|
|
131
|
+
validate_only: z.coerce.boolean().optional(),
|
|
129
132
|
});
|
|
130
133
|
// --------------------
|
|
131
134
|
// LogPlaybookUsageParams
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.1.
|
|
1
|
+
export declare const version = "0.1.25";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.1.
|
|
1
|
+
export const version = '0.1.25';
|