@yourgpt/copilot-sdk 0.1.0 → 0.1.1
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/README.md +25 -23
- package/dist/{chunk-QUGTRQSS.js → chunk-FO75W5UI.js} +30 -23
- package/dist/chunk-FO75W5UI.js.map +1 -0
- package/dist/{chunk-2ZCWVAAK.cjs → chunk-IH7WXWX4.cjs} +2 -2
- package/dist/{chunk-2ZCWVAAK.cjs.map → chunk-IH7WXWX4.cjs.map} +1 -1
- package/dist/{chunk-N4OA2J32.js → chunk-QWQELTEB.js} +2 -2
- package/dist/{chunk-N4OA2J32.js.map → chunk-QWQELTEB.js.map} +1 -1
- package/dist/{chunk-W6KQT7YZ.cjs → chunk-R452HH3J.cjs} +53 -46
- package/dist/chunk-R452HH3J.cjs.map +1 -0
- package/dist/core/index.cjs +71 -71
- package/dist/core/index.d.cts +13 -4
- package/dist/core/index.d.ts +13 -4
- package/dist/core/index.js +1 -1
- package/dist/react/index.cjs +34 -34
- package/dist/react/index.d.cts +28 -6
- package/dist/react/index.d.ts +28 -6
- package/dist/react/index.js +2 -2
- package/dist/{thread-C2FjuGLb.d.cts → thread-CLmfwine.d.cts} +1 -516
- package/dist/{thread-C2FjuGLb.d.ts → thread-CLmfwine.d.ts} +1 -516
- package/dist/tools-eeJ5iEC4.d.cts +595 -0
- package/dist/tools-eeJ5iEC4.d.ts +595 -0
- package/dist/ui/index.cjs +136 -46
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +68 -6
- package/dist/ui/index.d.ts +68 -6
- package/dist/ui/index.js +135 -45
- package/dist/ui/index.js.map +1 -1
- package/package.json +9 -8
- package/dist/chunk-QUGTRQSS.js.map +0 -1
- package/dist/chunk-W6KQT7YZ.cjs.map +0 -1
package/dist/ui/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkR452HH3J_cjs = require('../chunk-R452HH3J.cjs');
|
|
4
|
+
require('../chunk-IH7WXWX4.cjs');
|
|
5
5
|
var clsx = require('clsx');
|
|
6
6
|
var tailwindMerge = require('tailwind-merge');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -3055,6 +3055,7 @@ function DefaultMessage({
|
|
|
3055
3055
|
size = "sm",
|
|
3056
3056
|
isLastMessage = false,
|
|
3057
3057
|
isLoading = false,
|
|
3058
|
+
registeredTools,
|
|
3058
3059
|
toolRenderers,
|
|
3059
3060
|
onApproveToolExecution,
|
|
3060
3061
|
onRejectToolExecution,
|
|
@@ -3114,13 +3115,19 @@ function DefaultMessage({
|
|
|
3114
3115
|
const completedTools = message.toolExecutions?.filter(
|
|
3115
3116
|
(exec) => exec.approvalStatus !== "required"
|
|
3116
3117
|
);
|
|
3117
|
-
const
|
|
3118
|
-
(
|
|
3118
|
+
const hasCustomRender = (toolName) => {
|
|
3119
|
+
if (toolRenderers?.[toolName]) return true;
|
|
3120
|
+
const toolDef = registeredTools?.find((t) => t.name === toolName);
|
|
3121
|
+
if (toolDef?.render) return true;
|
|
3122
|
+
return false;
|
|
3123
|
+
};
|
|
3124
|
+
const toolsWithCustomRender = completedTools?.filter(
|
|
3125
|
+
(exec) => hasCustomRender(exec.name)
|
|
3119
3126
|
);
|
|
3120
|
-
const
|
|
3121
|
-
(exec) => !
|
|
3127
|
+
const toolsWithoutCustomRender = completedTools?.filter(
|
|
3128
|
+
(exec) => !hasCustomRender(exec.name)
|
|
3122
3129
|
);
|
|
3123
|
-
const toolSteps =
|
|
3130
|
+
const toolSteps = toolsWithoutCustomRender?.map((exec) => ({
|
|
3124
3131
|
id: exec.id,
|
|
3125
3132
|
name: exec.name,
|
|
3126
3133
|
args: exec.args,
|
|
@@ -3159,36 +3166,97 @@ function DefaultMessage({
|
|
|
3159
3166
|
children: cleanContent
|
|
3160
3167
|
}
|
|
3161
3168
|
),
|
|
3162
|
-
|
|
3163
|
-
const Renderer = toolRenderers[exec.name];
|
|
3169
|
+
toolsWithCustomRender && toolsWithCustomRender.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 space-y-2", children: toolsWithCustomRender.map((exec) => {
|
|
3170
|
+
const Renderer = toolRenderers?.[exec.name];
|
|
3171
|
+
if (Renderer) {
|
|
3172
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3173
|
+
Renderer,
|
|
3174
|
+
{
|
|
3175
|
+
execution: {
|
|
3176
|
+
id: exec.id,
|
|
3177
|
+
name: exec.name,
|
|
3178
|
+
args: exec.args,
|
|
3179
|
+
status: exec.status,
|
|
3180
|
+
result: exec.result,
|
|
3181
|
+
error: exec.error,
|
|
3182
|
+
approvalStatus: exec.approvalStatus
|
|
3183
|
+
}
|
|
3184
|
+
},
|
|
3185
|
+
exec.id
|
|
3186
|
+
);
|
|
3187
|
+
}
|
|
3188
|
+
const toolDef = registeredTools?.find(
|
|
3189
|
+
(t) => t.name === exec.name
|
|
3190
|
+
);
|
|
3191
|
+
if (toolDef?.render) {
|
|
3192
|
+
let status = "pending";
|
|
3193
|
+
if (exec.status === "executing") status = "executing";
|
|
3194
|
+
else if (exec.status === "completed") status = "completed";
|
|
3195
|
+
else if (exec.status === "error" || exec.status === "failed" || exec.status === "rejected")
|
|
3196
|
+
status = "error";
|
|
3197
|
+
const renderProps = {
|
|
3198
|
+
status,
|
|
3199
|
+
args: exec.args,
|
|
3200
|
+
result: exec.result,
|
|
3201
|
+
error: exec.error,
|
|
3202
|
+
toolCallId: exec.id,
|
|
3203
|
+
toolName: exec.name
|
|
3204
|
+
};
|
|
3205
|
+
const output = toolDef.render(renderProps);
|
|
3206
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React8__namespace.Fragment, { children: output }, exec.id);
|
|
3207
|
+
}
|
|
3208
|
+
return null;
|
|
3209
|
+
}) }),
|
|
3210
|
+
toolSteps && toolSteps.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 rounded-lg bg-muted/50 px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ToolSteps, { steps: toolSteps }) }),
|
|
3211
|
+
pendingApprovalTools && pendingApprovalTools.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 space-y-2", children: pendingApprovalTools.map((tool) => {
|
|
3212
|
+
const approvalCallbacks = {
|
|
3213
|
+
onApprove: (extraData) => onApproveToolExecution?.(tool.id, extraData),
|
|
3214
|
+
onReject: (reason) => onRejectToolExecution?.(tool.id, reason),
|
|
3215
|
+
message: tool.approvalMessage
|
|
3216
|
+
};
|
|
3217
|
+
const CustomRenderer = toolRenderers?.[tool.name];
|
|
3218
|
+
if (CustomRenderer) {
|
|
3219
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3220
|
+
CustomRenderer,
|
|
3221
|
+
{
|
|
3222
|
+
execution: tool,
|
|
3223
|
+
approval: approvalCallbacks
|
|
3224
|
+
},
|
|
3225
|
+
tool.id
|
|
3226
|
+
);
|
|
3227
|
+
}
|
|
3228
|
+
const toolDef = registeredTools?.find(
|
|
3229
|
+
(t) => t.name === tool.name
|
|
3230
|
+
);
|
|
3231
|
+
if (toolDef?.render) {
|
|
3232
|
+
const renderProps = {
|
|
3233
|
+
status: "approval-required",
|
|
3234
|
+
args: tool.args,
|
|
3235
|
+
result: tool.result,
|
|
3236
|
+
error: tool.error,
|
|
3237
|
+
toolCallId: tool.id,
|
|
3238
|
+
toolName: tool.name,
|
|
3239
|
+
approval: approvalCallbacks
|
|
3240
|
+
};
|
|
3241
|
+
const output = toolDef.render(renderProps);
|
|
3242
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React8__namespace.Fragment, { children: output }, tool.id);
|
|
3243
|
+
}
|
|
3164
3244
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3165
|
-
|
|
3245
|
+
PermissionConfirmation,
|
|
3166
3246
|
{
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3247
|
+
state: "pending",
|
|
3248
|
+
toolName: tool.name,
|
|
3249
|
+
message: tool.approvalMessage || `This tool wants to execute. Do you approve?`,
|
|
3250
|
+
onApprove: (permissionLevel) => onApproveToolExecution?.(
|
|
3251
|
+
tool.id,
|
|
3252
|
+
void 0,
|
|
3253
|
+
permissionLevel
|
|
3254
|
+
),
|
|
3255
|
+
onReject: (permissionLevel) => onRejectToolExecution?.(tool.id, void 0, permissionLevel)
|
|
3176
3256
|
},
|
|
3177
|
-
|
|
3257
|
+
tool.id
|
|
3178
3258
|
);
|
|
3179
3259
|
}) }),
|
|
3180
|
-
toolSteps && toolSteps.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 rounded-lg bg-muted/50 px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ToolSteps, { steps: toolSteps }) }),
|
|
3181
|
-
pendingApprovalTools && pendingApprovalTools.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 space-y-2", children: pendingApprovalTools.map((tool) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3182
|
-
PermissionConfirmation,
|
|
3183
|
-
{
|
|
3184
|
-
state: "pending",
|
|
3185
|
-
toolName: tool.name,
|
|
3186
|
-
message: tool.approvalMessage || `This tool wants to execute. Do you approve?`,
|
|
3187
|
-
onApprove: (permissionLevel) => onApproveToolExecution?.(tool.id, permissionLevel),
|
|
3188
|
-
onReject: (permissionLevel) => onRejectToolExecution?.(tool.id, void 0, permissionLevel)
|
|
3189
|
-
},
|
|
3190
|
-
tool.id
|
|
3191
|
-
)) }),
|
|
3192
3260
|
message.attachments && message.attachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 flex flex-wrap gap-2", children: message.attachments.map((attachment, index) => /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { attachment }, index)) }),
|
|
3193
3261
|
shouldShowFollowUps && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3194
3262
|
FollowUpQuestions,
|
|
@@ -3339,6 +3407,7 @@ function Chat({
|
|
|
3339
3407
|
onSuggestionClick,
|
|
3340
3408
|
// Tool Executions
|
|
3341
3409
|
isProcessing = false,
|
|
3410
|
+
registeredTools,
|
|
3342
3411
|
toolRenderers,
|
|
3343
3412
|
onApproveToolExecution,
|
|
3344
3413
|
onRejectToolExecution,
|
|
@@ -3583,6 +3652,7 @@ function Chat({
|
|
|
3583
3652
|
size: fontSize,
|
|
3584
3653
|
isLastMessage,
|
|
3585
3654
|
isLoading,
|
|
3655
|
+
registeredTools,
|
|
3586
3656
|
toolRenderers,
|
|
3587
3657
|
onApproveToolExecution,
|
|
3588
3658
|
onRejectToolExecution,
|
|
@@ -3761,6 +3831,7 @@ function ToolExecutionMessage({
|
|
|
3761
3831
|
assistantAvatar = { fallback: "AI" },
|
|
3762
3832
|
onApprove,
|
|
3763
3833
|
onReject,
|
|
3834
|
+
toolRenderers,
|
|
3764
3835
|
className
|
|
3765
3836
|
}) {
|
|
3766
3837
|
if (!executions || executions.length === 0) return null;
|
|
@@ -3844,17 +3915,34 @@ function ToolExecutionMessage({
|
|
|
3844
3915
|
),
|
|
3845
3916
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-muted-foreground", children: hasExecuting ? "Running tools..." : allCompleted ? `${executions.length} tool${executions.length > 1 ? "s" : ""} completed` : "Tools" })
|
|
3846
3917
|
] }) }),
|
|
3847
|
-
pendingApprovals.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2 space-y-2", children: pendingApprovals.map((tool) =>
|
|
3848
|
-
|
|
3849
|
-
{
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3918
|
+
pendingApprovals.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2 space-y-2", children: pendingApprovals.map((tool) => {
|
|
3919
|
+
const CustomRenderer = toolRenderers?.[tool.name];
|
|
3920
|
+
if (CustomRenderer) {
|
|
3921
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3922
|
+
CustomRenderer,
|
|
3923
|
+
{
|
|
3924
|
+
execution: tool,
|
|
3925
|
+
approval: {
|
|
3926
|
+
onApprove: (extraData) => onApprove?.(tool.id, extraData),
|
|
3927
|
+
onReject: (reason) => onReject?.(tool.id, reason),
|
|
3928
|
+
message: tool.approvalMessage
|
|
3929
|
+
}
|
|
3930
|
+
},
|
|
3931
|
+
tool.id
|
|
3932
|
+
);
|
|
3933
|
+
}
|
|
3934
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3935
|
+
PermissionConfirmation,
|
|
3936
|
+
{
|
|
3937
|
+
state: "pending",
|
|
3938
|
+
toolName: tool.name,
|
|
3939
|
+
message: tool.approvalMessage || `This tool wants to execute. Do you approve?`,
|
|
3940
|
+
onApprove: (permissionLevel) => onApprove?.(tool.id, void 0, permissionLevel),
|
|
3941
|
+
onReject: (permissionLevel) => onReject?.(tool.id, void 0, permissionLevel)
|
|
3942
|
+
},
|
|
3943
|
+
tool.id
|
|
3944
|
+
);
|
|
3945
|
+
}) }),
|
|
3858
3946
|
toolSteps.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border bg-card px-3 py-2.5 shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsx(ToolSteps, { steps: toolSteps }) })
|
|
3859
3947
|
] })
|
|
3860
3948
|
] });
|
|
@@ -3867,8 +3955,9 @@ function CopilotChat(props) {
|
|
|
3867
3955
|
stop,
|
|
3868
3956
|
toolExecutions: rawToolExecutions,
|
|
3869
3957
|
approveToolExecution,
|
|
3870
|
-
rejectToolExecution
|
|
3871
|
-
|
|
3958
|
+
rejectToolExecution,
|
|
3959
|
+
registeredTools
|
|
3960
|
+
} = chunkR452HH3J_cjs.useCopilot();
|
|
3872
3961
|
const toolExecutions = rawToolExecutions.map(
|
|
3873
3962
|
(exec) => ({
|
|
3874
3963
|
id: exec.id,
|
|
@@ -3991,7 +4080,8 @@ function CopilotChat(props) {
|
|
|
3991
4080
|
suggestions,
|
|
3992
4081
|
isProcessing: isProcessingToolResults,
|
|
3993
4082
|
onApproveToolExecution: approveToolExecution,
|
|
3994
|
-
onRejectToolExecution: rejectToolExecution
|
|
4083
|
+
onRejectToolExecution: rejectToolExecution,
|
|
4084
|
+
registeredTools
|
|
3995
4085
|
}
|
|
3996
4086
|
);
|
|
3997
4087
|
}
|