@contractspec/module.ai-chat 4.1.0 → 4.1.2
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/browser/core/index.js +7 -2
- package/dist/browser/index.js +23 -6
- package/dist/browser/presentation/components/index.js +23 -6
- package/dist/browser/presentation/hooks/index.js +21 -4
- package/dist/browser/presentation/index.js +23 -6
- package/dist/core/agent-adapter.d.ts +8 -8
- package/dist/core/contracts-context.d.ts +10 -10
- package/dist/core/index.js +7 -2
- package/dist/index.js +23 -6
- package/dist/node/core/index.js +7 -2
- package/dist/node/index.js +23 -6
- package/dist/node/presentation/components/index.js +23 -6
- package/dist/node/presentation/hooks/index.js +21 -4
- package/dist/node/presentation/index.js +23 -6
- package/dist/presentation/components/index.js +23 -6
- package/dist/presentation/hooks/index.js +21 -4
- package/dist/presentation/index.js +23 -6
- package/package.json +13 -13
|
@@ -515,7 +515,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
515
515
|
// src/core/surface-planner-tools.ts
|
|
516
516
|
import { tool as tool3 } from "ai";
|
|
517
517
|
import { z as z3 } from "zod";
|
|
518
|
-
import {
|
|
518
|
+
import {
|
|
519
|
+
validatePatchProposal
|
|
520
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
519
521
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
520
522
|
var VALID_OPS = [
|
|
521
523
|
"insert-node",
|
|
@@ -651,7 +653,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
651
653
|
allowedPatchOps: constraints.allowedOps,
|
|
652
654
|
allowedSlots: [...constraints.allowedSlots],
|
|
653
655
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
654
|
-
actions: plan.actions.map((a) => ({
|
|
656
|
+
actions: plan.actions.map((a) => ({
|
|
657
|
+
actionId: a.actionId,
|
|
658
|
+
title: a.title
|
|
659
|
+
})),
|
|
655
660
|
preferences: {
|
|
656
661
|
guidance: "hints",
|
|
657
662
|
density: "standard",
|
package/dist/browser/index.js
CHANGED
|
@@ -668,7 +668,7 @@ function ToolResultRenderer({
|
|
|
668
668
|
const rendered = presentationRenderer(result.presentationKey, result.data);
|
|
669
669
|
if (rendered != null) {
|
|
670
670
|
return /* @__PURE__ */ jsx3("div", {
|
|
671
|
-
className: "mt-2 rounded-md border
|
|
671
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
672
672
|
children: rendered
|
|
673
673
|
});
|
|
674
674
|
}
|
|
@@ -677,7 +677,7 @@ function ToolResultRenderer({
|
|
|
677
677
|
const rendered = formRenderer(result.formKey, result.defaultValues);
|
|
678
678
|
if (rendered != null) {
|
|
679
679
|
return /* @__PURE__ */ jsx3("div", {
|
|
680
|
-
className: "mt-2 rounded-md border
|
|
680
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
681
681
|
children: rendered
|
|
682
682
|
});
|
|
683
683
|
}
|
|
@@ -2551,7 +2551,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
2551
2551
|
// src/core/surface-planner-tools.ts
|
|
2552
2552
|
import { tool as tool3 } from "ai";
|
|
2553
2553
|
import { z as z3 } from "zod";
|
|
2554
|
-
import {
|
|
2554
|
+
import {
|
|
2555
|
+
validatePatchProposal
|
|
2556
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
2555
2557
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
2556
2558
|
var VALID_OPS = [
|
|
2557
2559
|
"insert-node",
|
|
@@ -2687,7 +2689,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
2687
2689
|
allowedPatchOps: constraints.allowedOps,
|
|
2688
2690
|
allowedSlots: [...constraints.allowedSlots],
|
|
2689
2691
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
2690
|
-
actions: plan.actions.map((a) => ({
|
|
2692
|
+
actions: plan.actions.map((a) => ({
|
|
2693
|
+
actionId: a.actionId,
|
|
2694
|
+
title: a.title
|
|
2695
|
+
})),
|
|
2691
2696
|
preferences: {
|
|
2692
2697
|
guidance: "hints",
|
|
2693
2698
|
density: "standard",
|
|
@@ -3459,7 +3464,17 @@ function useChat(options = {}) {
|
|
|
3459
3464
|
setIsLoading(false);
|
|
3460
3465
|
abortControllerRef.current = null;
|
|
3461
3466
|
}
|
|
3462
|
-
}, [
|
|
3467
|
+
}, [
|
|
3468
|
+
conversationId,
|
|
3469
|
+
streaming,
|
|
3470
|
+
onSend,
|
|
3471
|
+
onResponse,
|
|
3472
|
+
onError,
|
|
3473
|
+
onUsage,
|
|
3474
|
+
messages,
|
|
3475
|
+
agentMode,
|
|
3476
|
+
store
|
|
3477
|
+
]);
|
|
3463
3478
|
const clearConversation = React11.useCallback(() => {
|
|
3464
3479
|
setMessages([]);
|
|
3465
3480
|
setConversation(null);
|
|
@@ -3487,7 +3502,9 @@ function useChat(options = {}) {
|
|
|
3487
3502
|
const msg = messages.find((m) => m.id === messageId);
|
|
3488
3503
|
if (!msg || msg.role !== "user")
|
|
3489
3504
|
return;
|
|
3490
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3505
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3506
|
+
content: newContent
|
|
3507
|
+
});
|
|
3491
3508
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
3492
3509
|
if (truncated) {
|
|
3493
3510
|
setMessages(truncated.messages);
|
|
@@ -269,7 +269,7 @@ function ToolResultRenderer({
|
|
|
269
269
|
const rendered = presentationRenderer(result.presentationKey, result.data);
|
|
270
270
|
if (rendered != null) {
|
|
271
271
|
return /* @__PURE__ */ jsx3("div", {
|
|
272
|
-
className: "mt-2 rounded-md border
|
|
272
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
273
273
|
children: rendered
|
|
274
274
|
});
|
|
275
275
|
}
|
|
@@ -278,7 +278,7 @@ function ToolResultRenderer({
|
|
|
278
278
|
const rendered = formRenderer(result.formKey, result.defaultValues);
|
|
279
279
|
if (rendered != null) {
|
|
280
280
|
return /* @__PURE__ */ jsx3("div", {
|
|
281
|
-
className: "mt-2 rounded-md border
|
|
281
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
282
282
|
children: rendered
|
|
283
283
|
});
|
|
284
284
|
}
|
|
@@ -2152,7 +2152,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
2152
2152
|
// src/core/surface-planner-tools.ts
|
|
2153
2153
|
import { tool as tool3 } from "ai";
|
|
2154
2154
|
import { z as z3 } from "zod";
|
|
2155
|
-
import {
|
|
2155
|
+
import {
|
|
2156
|
+
validatePatchProposal
|
|
2157
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
2156
2158
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
2157
2159
|
var VALID_OPS = [
|
|
2158
2160
|
"insert-node",
|
|
@@ -2288,7 +2290,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
2288
2290
|
allowedPatchOps: constraints.allowedOps,
|
|
2289
2291
|
allowedSlots: [...constraints.allowedSlots],
|
|
2290
2292
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
2291
|
-
actions: plan.actions.map((a) => ({
|
|
2293
|
+
actions: plan.actions.map((a) => ({
|
|
2294
|
+
actionId: a.actionId,
|
|
2295
|
+
title: a.title
|
|
2296
|
+
})),
|
|
2292
2297
|
preferences: {
|
|
2293
2298
|
guidance: "hints",
|
|
2294
2299
|
density: "standard",
|
|
@@ -3060,7 +3065,17 @@ function useChat(options = {}) {
|
|
|
3060
3065
|
setIsLoading(false);
|
|
3061
3066
|
abortControllerRef.current = null;
|
|
3062
3067
|
}
|
|
3063
|
-
}, [
|
|
3068
|
+
}, [
|
|
3069
|
+
conversationId,
|
|
3070
|
+
streaming,
|
|
3071
|
+
onSend,
|
|
3072
|
+
onResponse,
|
|
3073
|
+
onError,
|
|
3074
|
+
onUsage,
|
|
3075
|
+
messages,
|
|
3076
|
+
agentMode,
|
|
3077
|
+
store
|
|
3078
|
+
]);
|
|
3064
3079
|
const clearConversation = React11.useCallback(() => {
|
|
3065
3080
|
setMessages([]);
|
|
3066
3081
|
setConversation(null);
|
|
@@ -3088,7 +3103,9 @@ function useChat(options = {}) {
|
|
|
3088
3103
|
const msg = messages.find((m) => m.id === messageId);
|
|
3089
3104
|
if (!msg || msg.role !== "user")
|
|
3090
3105
|
return;
|
|
3091
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3106
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3107
|
+
content: newContent
|
|
3108
|
+
});
|
|
3092
3109
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
3093
3110
|
if (truncated) {
|
|
3094
3111
|
setMessages(truncated.messages);
|
|
@@ -522,7 +522,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
522
522
|
// src/core/surface-planner-tools.ts
|
|
523
523
|
import { tool as tool3 } from "ai";
|
|
524
524
|
import { z as z3 } from "zod";
|
|
525
|
-
import {
|
|
525
|
+
import {
|
|
526
|
+
validatePatchProposal
|
|
527
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
526
528
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
527
529
|
var VALID_OPS = [
|
|
528
530
|
"insert-node",
|
|
@@ -658,7 +660,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
658
660
|
allowedPatchOps: constraints.allowedOps,
|
|
659
661
|
allowedSlots: [...constraints.allowedSlots],
|
|
660
662
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
661
|
-
actions: plan.actions.map((a) => ({
|
|
663
|
+
actions: plan.actions.map((a) => ({
|
|
664
|
+
actionId: a.actionId,
|
|
665
|
+
title: a.title
|
|
666
|
+
})),
|
|
662
667
|
preferences: {
|
|
663
668
|
guidance: "hints",
|
|
664
669
|
density: "standard",
|
|
@@ -1430,7 +1435,17 @@ function useChat(options = {}) {
|
|
|
1430
1435
|
setIsLoading(false);
|
|
1431
1436
|
abortControllerRef.current = null;
|
|
1432
1437
|
}
|
|
1433
|
-
}, [
|
|
1438
|
+
}, [
|
|
1439
|
+
conversationId,
|
|
1440
|
+
streaming,
|
|
1441
|
+
onSend,
|
|
1442
|
+
onResponse,
|
|
1443
|
+
onError,
|
|
1444
|
+
onUsage,
|
|
1445
|
+
messages,
|
|
1446
|
+
agentMode,
|
|
1447
|
+
store
|
|
1448
|
+
]);
|
|
1434
1449
|
const clearConversation = React.useCallback(() => {
|
|
1435
1450
|
setMessages([]);
|
|
1436
1451
|
setConversation(null);
|
|
@@ -1458,7 +1473,9 @@ function useChat(options = {}) {
|
|
|
1458
1473
|
const msg = messages.find((m) => m.id === messageId);
|
|
1459
1474
|
if (!msg || msg.role !== "user")
|
|
1460
1475
|
return;
|
|
1461
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
1476
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
1477
|
+
content: newContent
|
|
1478
|
+
});
|
|
1462
1479
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
1463
1480
|
if (truncated) {
|
|
1464
1481
|
setMessages(truncated.messages);
|
|
@@ -269,7 +269,7 @@ function ToolResultRenderer({
|
|
|
269
269
|
const rendered = presentationRenderer(result.presentationKey, result.data);
|
|
270
270
|
if (rendered != null) {
|
|
271
271
|
return /* @__PURE__ */ jsx3("div", {
|
|
272
|
-
className: "mt-2 rounded-md border
|
|
272
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
273
273
|
children: rendered
|
|
274
274
|
});
|
|
275
275
|
}
|
|
@@ -278,7 +278,7 @@ function ToolResultRenderer({
|
|
|
278
278
|
const rendered = formRenderer(result.formKey, result.defaultValues);
|
|
279
279
|
if (rendered != null) {
|
|
280
280
|
return /* @__PURE__ */ jsx3("div", {
|
|
281
|
-
className: "mt-2 rounded-md border
|
|
281
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
282
282
|
children: rendered
|
|
283
283
|
});
|
|
284
284
|
}
|
|
@@ -2152,7 +2152,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
2152
2152
|
// src/core/surface-planner-tools.ts
|
|
2153
2153
|
import { tool as tool3 } from "ai";
|
|
2154
2154
|
import { z as z3 } from "zod";
|
|
2155
|
-
import {
|
|
2155
|
+
import {
|
|
2156
|
+
validatePatchProposal
|
|
2157
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
2156
2158
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
2157
2159
|
var VALID_OPS = [
|
|
2158
2160
|
"insert-node",
|
|
@@ -2288,7 +2290,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
2288
2290
|
allowedPatchOps: constraints.allowedOps,
|
|
2289
2291
|
allowedSlots: [...constraints.allowedSlots],
|
|
2290
2292
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
2291
|
-
actions: plan.actions.map((a) => ({
|
|
2293
|
+
actions: plan.actions.map((a) => ({
|
|
2294
|
+
actionId: a.actionId,
|
|
2295
|
+
title: a.title
|
|
2296
|
+
})),
|
|
2292
2297
|
preferences: {
|
|
2293
2298
|
guidance: "hints",
|
|
2294
2299
|
density: "standard",
|
|
@@ -3060,7 +3065,17 @@ function useChat(options = {}) {
|
|
|
3060
3065
|
setIsLoading(false);
|
|
3061
3066
|
abortControllerRef.current = null;
|
|
3062
3067
|
}
|
|
3063
|
-
}, [
|
|
3068
|
+
}, [
|
|
3069
|
+
conversationId,
|
|
3070
|
+
streaming,
|
|
3071
|
+
onSend,
|
|
3072
|
+
onResponse,
|
|
3073
|
+
onError,
|
|
3074
|
+
onUsage,
|
|
3075
|
+
messages,
|
|
3076
|
+
agentMode,
|
|
3077
|
+
store
|
|
3078
|
+
]);
|
|
3064
3079
|
const clearConversation = React11.useCallback(() => {
|
|
3065
3080
|
setMessages([]);
|
|
3066
3081
|
setConversation(null);
|
|
@@ -3088,7 +3103,9 @@ function useChat(options = {}) {
|
|
|
3088
3103
|
const msg = messages.find((m) => m.id === messageId);
|
|
3089
3104
|
if (!msg || msg.role !== "user")
|
|
3090
3105
|
return;
|
|
3091
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3106
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3107
|
+
content: newContent
|
|
3108
|
+
});
|
|
3092
3109
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
3093
3110
|
if (truncated) {
|
|
3094
3111
|
setMessages(truncated.messages);
|
|
@@ -8,16 +8,16 @@ export interface ChatAgentAdapter {
|
|
|
8
8
|
signal?: AbortSignal;
|
|
9
9
|
}): Promise<{
|
|
10
10
|
text: string;
|
|
11
|
-
toolCalls?:
|
|
11
|
+
toolCalls?: {
|
|
12
12
|
toolCallId: string;
|
|
13
13
|
toolName: string;
|
|
14
14
|
args: unknown;
|
|
15
|
-
}
|
|
16
|
-
toolResults?:
|
|
15
|
+
}[];
|
|
16
|
+
toolResults?: {
|
|
17
17
|
toolCallId: string;
|
|
18
18
|
toolName: string;
|
|
19
19
|
output: unknown;
|
|
20
|
-
}
|
|
20
|
+
}[];
|
|
21
21
|
usage?: {
|
|
22
22
|
inputTokens: number;
|
|
23
23
|
outputTokens: number;
|
|
@@ -35,16 +35,16 @@ export declare function createChatAgentAdapter(agent: {
|
|
|
35
35
|
signal?: AbortSignal;
|
|
36
36
|
}): Promise<{
|
|
37
37
|
text: string;
|
|
38
|
-
toolCalls?:
|
|
38
|
+
toolCalls?: {
|
|
39
39
|
toolCallId: string;
|
|
40
40
|
toolName: string;
|
|
41
41
|
args: unknown;
|
|
42
|
-
}
|
|
43
|
-
toolResults?:
|
|
42
|
+
}[];
|
|
43
|
+
toolResults?: {
|
|
44
44
|
toolCallId: string;
|
|
45
45
|
toolName: string;
|
|
46
46
|
output: unknown;
|
|
47
|
-
}
|
|
47
|
+
}[];
|
|
48
48
|
usage?: {
|
|
49
49
|
inputTokens: number;
|
|
50
50
|
outputTokens: number;
|
|
@@ -5,39 +5,39 @@
|
|
|
5
5
|
import type { AgentToolConfig } from '@contractspec/lib.ai-agent';
|
|
6
6
|
export interface ContractsContextConfig {
|
|
7
7
|
/** Agent specs (for tool schemas, instructions) */
|
|
8
|
-
agentSpecs?:
|
|
8
|
+
agentSpecs?: {
|
|
9
9
|
key: string;
|
|
10
10
|
tools?: AgentToolConfig[];
|
|
11
|
-
}
|
|
11
|
+
}[];
|
|
12
12
|
/** Data view specs (for query suggestions, filters) */
|
|
13
|
-
dataViewSpecs?:
|
|
13
|
+
dataViewSpecs?: {
|
|
14
14
|
key: string;
|
|
15
15
|
meta: {
|
|
16
16
|
title?: string;
|
|
17
17
|
};
|
|
18
18
|
source?: unknown;
|
|
19
|
-
}
|
|
19
|
+
}[];
|
|
20
20
|
/** Form specs (for rendering or generating form configs) */
|
|
21
|
-
formSpecs?:
|
|
21
|
+
formSpecs?: {
|
|
22
22
|
key: string;
|
|
23
23
|
meta: {
|
|
24
24
|
title?: string;
|
|
25
25
|
};
|
|
26
26
|
fields?: unknown[];
|
|
27
|
-
}
|
|
27
|
+
}[];
|
|
28
28
|
/** Presentation specs (for rendering tool outputs) */
|
|
29
|
-
presentationSpecs?:
|
|
29
|
+
presentationSpecs?: {
|
|
30
30
|
key: string;
|
|
31
31
|
meta: {
|
|
32
32
|
title?: string;
|
|
33
33
|
};
|
|
34
34
|
targets?: string[];
|
|
35
|
-
}
|
|
35
|
+
}[];
|
|
36
36
|
/** Operation refs the chat can invoke via tools */
|
|
37
|
-
operationRefs?:
|
|
37
|
+
operationRefs?: {
|
|
38
38
|
key: string;
|
|
39
39
|
version: string;
|
|
40
|
-
}
|
|
40
|
+
}[];
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Builds a prompt section describing available contracts-spec resources.
|
package/dist/core/index.js
CHANGED
|
@@ -510,7 +510,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
510
510
|
// src/core/surface-planner-tools.ts
|
|
511
511
|
import { tool as tool3 } from "ai";
|
|
512
512
|
import { z as z3 } from "zod";
|
|
513
|
-
import {
|
|
513
|
+
import {
|
|
514
|
+
validatePatchProposal
|
|
515
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
514
516
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
515
517
|
var VALID_OPS = [
|
|
516
518
|
"insert-node",
|
|
@@ -646,7 +648,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
646
648
|
allowedPatchOps: constraints.allowedOps,
|
|
647
649
|
allowedSlots: [...constraints.allowedSlots],
|
|
648
650
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
649
|
-
actions: plan.actions.map((a) => ({
|
|
651
|
+
actions: plan.actions.map((a) => ({
|
|
652
|
+
actionId: a.actionId,
|
|
653
|
+
title: a.title
|
|
654
|
+
})),
|
|
650
655
|
preferences: {
|
|
651
656
|
guidance: "hints",
|
|
652
657
|
density: "standard",
|
package/dist/index.js
CHANGED
|
@@ -663,7 +663,7 @@ function ToolResultRenderer({
|
|
|
663
663
|
const rendered = presentationRenderer(result.presentationKey, result.data);
|
|
664
664
|
if (rendered != null) {
|
|
665
665
|
return /* @__PURE__ */ jsx3("div", {
|
|
666
|
-
className: "mt-2 rounded-md border
|
|
666
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
667
667
|
children: rendered
|
|
668
668
|
});
|
|
669
669
|
}
|
|
@@ -672,7 +672,7 @@ function ToolResultRenderer({
|
|
|
672
672
|
const rendered = formRenderer(result.formKey, result.defaultValues);
|
|
673
673
|
if (rendered != null) {
|
|
674
674
|
return /* @__PURE__ */ jsx3("div", {
|
|
675
|
-
className: "mt-2 rounded-md border
|
|
675
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
676
676
|
children: rendered
|
|
677
677
|
});
|
|
678
678
|
}
|
|
@@ -2546,7 +2546,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
2546
2546
|
// src/core/surface-planner-tools.ts
|
|
2547
2547
|
import { tool as tool3 } from "ai";
|
|
2548
2548
|
import { z as z3 } from "zod";
|
|
2549
|
-
import {
|
|
2549
|
+
import {
|
|
2550
|
+
validatePatchProposal
|
|
2551
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
2550
2552
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
2551
2553
|
var VALID_OPS = [
|
|
2552
2554
|
"insert-node",
|
|
@@ -2682,7 +2684,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
2682
2684
|
allowedPatchOps: constraints.allowedOps,
|
|
2683
2685
|
allowedSlots: [...constraints.allowedSlots],
|
|
2684
2686
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
2685
|
-
actions: plan.actions.map((a) => ({
|
|
2687
|
+
actions: plan.actions.map((a) => ({
|
|
2688
|
+
actionId: a.actionId,
|
|
2689
|
+
title: a.title
|
|
2690
|
+
})),
|
|
2686
2691
|
preferences: {
|
|
2687
2692
|
guidance: "hints",
|
|
2688
2693
|
density: "standard",
|
|
@@ -3454,7 +3459,17 @@ function useChat(options = {}) {
|
|
|
3454
3459
|
setIsLoading(false);
|
|
3455
3460
|
abortControllerRef.current = null;
|
|
3456
3461
|
}
|
|
3457
|
-
}, [
|
|
3462
|
+
}, [
|
|
3463
|
+
conversationId,
|
|
3464
|
+
streaming,
|
|
3465
|
+
onSend,
|
|
3466
|
+
onResponse,
|
|
3467
|
+
onError,
|
|
3468
|
+
onUsage,
|
|
3469
|
+
messages,
|
|
3470
|
+
agentMode,
|
|
3471
|
+
store
|
|
3472
|
+
]);
|
|
3458
3473
|
const clearConversation = React11.useCallback(() => {
|
|
3459
3474
|
setMessages([]);
|
|
3460
3475
|
setConversation(null);
|
|
@@ -3482,7 +3497,9 @@ function useChat(options = {}) {
|
|
|
3482
3497
|
const msg = messages.find((m) => m.id === messageId);
|
|
3483
3498
|
if (!msg || msg.role !== "user")
|
|
3484
3499
|
return;
|
|
3485
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3500
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3501
|
+
content: newContent
|
|
3502
|
+
});
|
|
3486
3503
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
3487
3504
|
if (truncated) {
|
|
3488
3505
|
setMessages(truncated.messages);
|
package/dist/node/core/index.js
CHANGED
|
@@ -510,7 +510,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
510
510
|
// src/core/surface-planner-tools.ts
|
|
511
511
|
import { tool as tool3 } from "ai";
|
|
512
512
|
import { z as z3 } from "zod";
|
|
513
|
-
import {
|
|
513
|
+
import {
|
|
514
|
+
validatePatchProposal
|
|
515
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
514
516
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
515
517
|
var VALID_OPS = [
|
|
516
518
|
"insert-node",
|
|
@@ -646,7 +648,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
646
648
|
allowedPatchOps: constraints.allowedOps,
|
|
647
649
|
allowedSlots: [...constraints.allowedSlots],
|
|
648
650
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
649
|
-
actions: plan.actions.map((a) => ({
|
|
651
|
+
actions: plan.actions.map((a) => ({
|
|
652
|
+
actionId: a.actionId,
|
|
653
|
+
title: a.title
|
|
654
|
+
})),
|
|
650
655
|
preferences: {
|
|
651
656
|
guidance: "hints",
|
|
652
657
|
density: "standard",
|
package/dist/node/index.js
CHANGED
|
@@ -663,7 +663,7 @@ function ToolResultRenderer({
|
|
|
663
663
|
const rendered = presentationRenderer(result.presentationKey, result.data);
|
|
664
664
|
if (rendered != null) {
|
|
665
665
|
return /* @__PURE__ */ jsx3("div", {
|
|
666
|
-
className: "mt-2 rounded-md border
|
|
666
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
667
667
|
children: rendered
|
|
668
668
|
});
|
|
669
669
|
}
|
|
@@ -672,7 +672,7 @@ function ToolResultRenderer({
|
|
|
672
672
|
const rendered = formRenderer(result.formKey, result.defaultValues);
|
|
673
673
|
if (rendered != null) {
|
|
674
674
|
return /* @__PURE__ */ jsx3("div", {
|
|
675
|
-
className: "mt-2 rounded-md border
|
|
675
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
676
676
|
children: rendered
|
|
677
677
|
});
|
|
678
678
|
}
|
|
@@ -2546,7 +2546,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
2546
2546
|
// src/core/surface-planner-tools.ts
|
|
2547
2547
|
import { tool as tool3 } from "ai";
|
|
2548
2548
|
import { z as z3 } from "zod";
|
|
2549
|
-
import {
|
|
2549
|
+
import {
|
|
2550
|
+
validatePatchProposal
|
|
2551
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
2550
2552
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
2551
2553
|
var VALID_OPS = [
|
|
2552
2554
|
"insert-node",
|
|
@@ -2682,7 +2684,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
2682
2684
|
allowedPatchOps: constraints.allowedOps,
|
|
2683
2685
|
allowedSlots: [...constraints.allowedSlots],
|
|
2684
2686
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
2685
|
-
actions: plan.actions.map((a) => ({
|
|
2687
|
+
actions: plan.actions.map((a) => ({
|
|
2688
|
+
actionId: a.actionId,
|
|
2689
|
+
title: a.title
|
|
2690
|
+
})),
|
|
2686
2691
|
preferences: {
|
|
2687
2692
|
guidance: "hints",
|
|
2688
2693
|
density: "standard",
|
|
@@ -3454,7 +3459,17 @@ function useChat(options = {}) {
|
|
|
3454
3459
|
setIsLoading(false);
|
|
3455
3460
|
abortControllerRef.current = null;
|
|
3456
3461
|
}
|
|
3457
|
-
}, [
|
|
3462
|
+
}, [
|
|
3463
|
+
conversationId,
|
|
3464
|
+
streaming,
|
|
3465
|
+
onSend,
|
|
3466
|
+
onResponse,
|
|
3467
|
+
onError,
|
|
3468
|
+
onUsage,
|
|
3469
|
+
messages,
|
|
3470
|
+
agentMode,
|
|
3471
|
+
store
|
|
3472
|
+
]);
|
|
3458
3473
|
const clearConversation = React11.useCallback(() => {
|
|
3459
3474
|
setMessages([]);
|
|
3460
3475
|
setConversation(null);
|
|
@@ -3482,7 +3497,9 @@ function useChat(options = {}) {
|
|
|
3482
3497
|
const msg = messages.find((m) => m.id === messageId);
|
|
3483
3498
|
if (!msg || msg.role !== "user")
|
|
3484
3499
|
return;
|
|
3485
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3500
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3501
|
+
content: newContent
|
|
3502
|
+
});
|
|
3486
3503
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
3487
3504
|
if (truncated) {
|
|
3488
3505
|
setMessages(truncated.messages);
|
|
@@ -264,7 +264,7 @@ function ToolResultRenderer({
|
|
|
264
264
|
const rendered = presentationRenderer(result.presentationKey, result.data);
|
|
265
265
|
if (rendered != null) {
|
|
266
266
|
return /* @__PURE__ */ jsx3("div", {
|
|
267
|
-
className: "mt-2 rounded-md border
|
|
267
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
268
268
|
children: rendered
|
|
269
269
|
});
|
|
270
270
|
}
|
|
@@ -273,7 +273,7 @@ function ToolResultRenderer({
|
|
|
273
273
|
const rendered = formRenderer(result.formKey, result.defaultValues);
|
|
274
274
|
if (rendered != null) {
|
|
275
275
|
return /* @__PURE__ */ jsx3("div", {
|
|
276
|
-
className: "mt-2 rounded-md border
|
|
276
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
277
277
|
children: rendered
|
|
278
278
|
});
|
|
279
279
|
}
|
|
@@ -2147,7 +2147,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
2147
2147
|
// src/core/surface-planner-tools.ts
|
|
2148
2148
|
import { tool as tool3 } from "ai";
|
|
2149
2149
|
import { z as z3 } from "zod";
|
|
2150
|
-
import {
|
|
2150
|
+
import {
|
|
2151
|
+
validatePatchProposal
|
|
2152
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
2151
2153
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
2152
2154
|
var VALID_OPS = [
|
|
2153
2155
|
"insert-node",
|
|
@@ -2283,7 +2285,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
2283
2285
|
allowedPatchOps: constraints.allowedOps,
|
|
2284
2286
|
allowedSlots: [...constraints.allowedSlots],
|
|
2285
2287
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
2286
|
-
actions: plan.actions.map((a) => ({
|
|
2288
|
+
actions: plan.actions.map((a) => ({
|
|
2289
|
+
actionId: a.actionId,
|
|
2290
|
+
title: a.title
|
|
2291
|
+
})),
|
|
2287
2292
|
preferences: {
|
|
2288
2293
|
guidance: "hints",
|
|
2289
2294
|
density: "standard",
|
|
@@ -3055,7 +3060,17 @@ function useChat(options = {}) {
|
|
|
3055
3060
|
setIsLoading(false);
|
|
3056
3061
|
abortControllerRef.current = null;
|
|
3057
3062
|
}
|
|
3058
|
-
}, [
|
|
3063
|
+
}, [
|
|
3064
|
+
conversationId,
|
|
3065
|
+
streaming,
|
|
3066
|
+
onSend,
|
|
3067
|
+
onResponse,
|
|
3068
|
+
onError,
|
|
3069
|
+
onUsage,
|
|
3070
|
+
messages,
|
|
3071
|
+
agentMode,
|
|
3072
|
+
store
|
|
3073
|
+
]);
|
|
3059
3074
|
const clearConversation = React11.useCallback(() => {
|
|
3060
3075
|
setMessages([]);
|
|
3061
3076
|
setConversation(null);
|
|
@@ -3083,7 +3098,9 @@ function useChat(options = {}) {
|
|
|
3083
3098
|
const msg = messages.find((m) => m.id === messageId);
|
|
3084
3099
|
if (!msg || msg.role !== "user")
|
|
3085
3100
|
return;
|
|
3086
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3101
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3102
|
+
content: newContent
|
|
3103
|
+
});
|
|
3087
3104
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
3088
3105
|
if (truncated) {
|
|
3089
3106
|
setMessages(truncated.messages);
|
|
@@ -517,7 +517,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
517
517
|
// src/core/surface-planner-tools.ts
|
|
518
518
|
import { tool as tool3 } from "ai";
|
|
519
519
|
import { z as z3 } from "zod";
|
|
520
|
-
import {
|
|
520
|
+
import {
|
|
521
|
+
validatePatchProposal
|
|
522
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
521
523
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
522
524
|
var VALID_OPS = [
|
|
523
525
|
"insert-node",
|
|
@@ -653,7 +655,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
653
655
|
allowedPatchOps: constraints.allowedOps,
|
|
654
656
|
allowedSlots: [...constraints.allowedSlots],
|
|
655
657
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
656
|
-
actions: plan.actions.map((a) => ({
|
|
658
|
+
actions: plan.actions.map((a) => ({
|
|
659
|
+
actionId: a.actionId,
|
|
660
|
+
title: a.title
|
|
661
|
+
})),
|
|
657
662
|
preferences: {
|
|
658
663
|
guidance: "hints",
|
|
659
664
|
density: "standard",
|
|
@@ -1425,7 +1430,17 @@ function useChat(options = {}) {
|
|
|
1425
1430
|
setIsLoading(false);
|
|
1426
1431
|
abortControllerRef.current = null;
|
|
1427
1432
|
}
|
|
1428
|
-
}, [
|
|
1433
|
+
}, [
|
|
1434
|
+
conversationId,
|
|
1435
|
+
streaming,
|
|
1436
|
+
onSend,
|
|
1437
|
+
onResponse,
|
|
1438
|
+
onError,
|
|
1439
|
+
onUsage,
|
|
1440
|
+
messages,
|
|
1441
|
+
agentMode,
|
|
1442
|
+
store
|
|
1443
|
+
]);
|
|
1429
1444
|
const clearConversation = React.useCallback(() => {
|
|
1430
1445
|
setMessages([]);
|
|
1431
1446
|
setConversation(null);
|
|
@@ -1453,7 +1468,9 @@ function useChat(options = {}) {
|
|
|
1453
1468
|
const msg = messages.find((m) => m.id === messageId);
|
|
1454
1469
|
if (!msg || msg.role !== "user")
|
|
1455
1470
|
return;
|
|
1456
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
1471
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
1472
|
+
content: newContent
|
|
1473
|
+
});
|
|
1457
1474
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
1458
1475
|
if (truncated) {
|
|
1459
1476
|
setMessages(truncated.messages);
|
|
@@ -264,7 +264,7 @@ function ToolResultRenderer({
|
|
|
264
264
|
const rendered = presentationRenderer(result.presentationKey, result.data);
|
|
265
265
|
if (rendered != null) {
|
|
266
266
|
return /* @__PURE__ */ jsx3("div", {
|
|
267
|
-
className: "mt-2 rounded-md border
|
|
267
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
268
268
|
children: rendered
|
|
269
269
|
});
|
|
270
270
|
}
|
|
@@ -273,7 +273,7 @@ function ToolResultRenderer({
|
|
|
273
273
|
const rendered = formRenderer(result.formKey, result.defaultValues);
|
|
274
274
|
if (rendered != null) {
|
|
275
275
|
return /* @__PURE__ */ jsx3("div", {
|
|
276
|
-
className: "mt-2 rounded-md border
|
|
276
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
277
277
|
children: rendered
|
|
278
278
|
});
|
|
279
279
|
}
|
|
@@ -2147,7 +2147,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
2147
2147
|
// src/core/surface-planner-tools.ts
|
|
2148
2148
|
import { tool as tool3 } from "ai";
|
|
2149
2149
|
import { z as z3 } from "zod";
|
|
2150
|
-
import {
|
|
2150
|
+
import {
|
|
2151
|
+
validatePatchProposal
|
|
2152
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
2151
2153
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
2152
2154
|
var VALID_OPS = [
|
|
2153
2155
|
"insert-node",
|
|
@@ -2283,7 +2285,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
2283
2285
|
allowedPatchOps: constraints.allowedOps,
|
|
2284
2286
|
allowedSlots: [...constraints.allowedSlots],
|
|
2285
2287
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
2286
|
-
actions: plan.actions.map((a) => ({
|
|
2288
|
+
actions: plan.actions.map((a) => ({
|
|
2289
|
+
actionId: a.actionId,
|
|
2290
|
+
title: a.title
|
|
2291
|
+
})),
|
|
2287
2292
|
preferences: {
|
|
2288
2293
|
guidance: "hints",
|
|
2289
2294
|
density: "standard",
|
|
@@ -3055,7 +3060,17 @@ function useChat(options = {}) {
|
|
|
3055
3060
|
setIsLoading(false);
|
|
3056
3061
|
abortControllerRef.current = null;
|
|
3057
3062
|
}
|
|
3058
|
-
}, [
|
|
3063
|
+
}, [
|
|
3064
|
+
conversationId,
|
|
3065
|
+
streaming,
|
|
3066
|
+
onSend,
|
|
3067
|
+
onResponse,
|
|
3068
|
+
onError,
|
|
3069
|
+
onUsage,
|
|
3070
|
+
messages,
|
|
3071
|
+
agentMode,
|
|
3072
|
+
store
|
|
3073
|
+
]);
|
|
3059
3074
|
const clearConversation = React11.useCallback(() => {
|
|
3060
3075
|
setMessages([]);
|
|
3061
3076
|
setConversation(null);
|
|
@@ -3083,7 +3098,9 @@ function useChat(options = {}) {
|
|
|
3083
3098
|
const msg = messages.find((m) => m.id === messageId);
|
|
3084
3099
|
if (!msg || msg.role !== "user")
|
|
3085
3100
|
return;
|
|
3086
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3101
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3102
|
+
content: newContent
|
|
3103
|
+
});
|
|
3087
3104
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
3088
3105
|
if (truncated) {
|
|
3089
3106
|
setMessages(truncated.messages);
|
|
@@ -264,7 +264,7 @@ function ToolResultRenderer({
|
|
|
264
264
|
const rendered = presentationRenderer(result.presentationKey, result.data);
|
|
265
265
|
if (rendered != null) {
|
|
266
266
|
return /* @__PURE__ */ jsx3("div", {
|
|
267
|
-
className: "mt-2 rounded-md border
|
|
267
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
268
268
|
children: rendered
|
|
269
269
|
});
|
|
270
270
|
}
|
|
@@ -273,7 +273,7 @@ function ToolResultRenderer({
|
|
|
273
273
|
const rendered = formRenderer(result.formKey, result.defaultValues);
|
|
274
274
|
if (rendered != null) {
|
|
275
275
|
return /* @__PURE__ */ jsx3("div", {
|
|
276
|
-
className: "mt-2 rounded-md border
|
|
276
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
277
277
|
children: rendered
|
|
278
278
|
});
|
|
279
279
|
}
|
|
@@ -2147,7 +2147,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
2147
2147
|
// src/core/surface-planner-tools.ts
|
|
2148
2148
|
import { tool as tool3 } from "ai";
|
|
2149
2149
|
import { z as z3 } from "zod";
|
|
2150
|
-
import {
|
|
2150
|
+
import {
|
|
2151
|
+
validatePatchProposal
|
|
2152
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
2151
2153
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
2152
2154
|
var VALID_OPS = [
|
|
2153
2155
|
"insert-node",
|
|
@@ -2283,7 +2285,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
2283
2285
|
allowedPatchOps: constraints.allowedOps,
|
|
2284
2286
|
allowedSlots: [...constraints.allowedSlots],
|
|
2285
2287
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
2286
|
-
actions: plan.actions.map((a) => ({
|
|
2288
|
+
actions: plan.actions.map((a) => ({
|
|
2289
|
+
actionId: a.actionId,
|
|
2290
|
+
title: a.title
|
|
2291
|
+
})),
|
|
2287
2292
|
preferences: {
|
|
2288
2293
|
guidance: "hints",
|
|
2289
2294
|
density: "standard",
|
|
@@ -3055,7 +3060,17 @@ function useChat(options = {}) {
|
|
|
3055
3060
|
setIsLoading(false);
|
|
3056
3061
|
abortControllerRef.current = null;
|
|
3057
3062
|
}
|
|
3058
|
-
}, [
|
|
3063
|
+
}, [
|
|
3064
|
+
conversationId,
|
|
3065
|
+
streaming,
|
|
3066
|
+
onSend,
|
|
3067
|
+
onResponse,
|
|
3068
|
+
onError,
|
|
3069
|
+
onUsage,
|
|
3070
|
+
messages,
|
|
3071
|
+
agentMode,
|
|
3072
|
+
store
|
|
3073
|
+
]);
|
|
3059
3074
|
const clearConversation = React11.useCallback(() => {
|
|
3060
3075
|
setMessages([]);
|
|
3061
3076
|
setConversation(null);
|
|
@@ -3083,7 +3098,9 @@ function useChat(options = {}) {
|
|
|
3083
3098
|
const msg = messages.find((m) => m.id === messageId);
|
|
3084
3099
|
if (!msg || msg.role !== "user")
|
|
3085
3100
|
return;
|
|
3086
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3101
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3102
|
+
content: newContent
|
|
3103
|
+
});
|
|
3087
3104
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
3088
3105
|
if (truncated) {
|
|
3089
3106
|
setMessages(truncated.messages);
|
|
@@ -517,7 +517,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
517
517
|
// src/core/surface-planner-tools.ts
|
|
518
518
|
import { tool as tool3 } from "ai";
|
|
519
519
|
import { z as z3 } from "zod";
|
|
520
|
-
import {
|
|
520
|
+
import {
|
|
521
|
+
validatePatchProposal
|
|
522
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
521
523
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
522
524
|
var VALID_OPS = [
|
|
523
525
|
"insert-node",
|
|
@@ -653,7 +655,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
653
655
|
allowedPatchOps: constraints.allowedOps,
|
|
654
656
|
allowedSlots: [...constraints.allowedSlots],
|
|
655
657
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
656
|
-
actions: plan.actions.map((a) => ({
|
|
658
|
+
actions: plan.actions.map((a) => ({
|
|
659
|
+
actionId: a.actionId,
|
|
660
|
+
title: a.title
|
|
661
|
+
})),
|
|
657
662
|
preferences: {
|
|
658
663
|
guidance: "hints",
|
|
659
664
|
density: "standard",
|
|
@@ -1425,7 +1430,17 @@ function useChat(options = {}) {
|
|
|
1425
1430
|
setIsLoading(false);
|
|
1426
1431
|
abortControllerRef.current = null;
|
|
1427
1432
|
}
|
|
1428
|
-
}, [
|
|
1433
|
+
}, [
|
|
1434
|
+
conversationId,
|
|
1435
|
+
streaming,
|
|
1436
|
+
onSend,
|
|
1437
|
+
onResponse,
|
|
1438
|
+
onError,
|
|
1439
|
+
onUsage,
|
|
1440
|
+
messages,
|
|
1441
|
+
agentMode,
|
|
1442
|
+
store
|
|
1443
|
+
]);
|
|
1429
1444
|
const clearConversation = React.useCallback(() => {
|
|
1430
1445
|
setMessages([]);
|
|
1431
1446
|
setConversation(null);
|
|
@@ -1453,7 +1468,9 @@ function useChat(options = {}) {
|
|
|
1453
1468
|
const msg = messages.find((m) => m.id === messageId);
|
|
1454
1469
|
if (!msg || msg.role !== "user")
|
|
1455
1470
|
return;
|
|
1456
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
1471
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
1472
|
+
content: newContent
|
|
1473
|
+
});
|
|
1457
1474
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
1458
1475
|
if (truncated) {
|
|
1459
1476
|
setMessages(truncated.messages);
|
|
@@ -264,7 +264,7 @@ function ToolResultRenderer({
|
|
|
264
264
|
const rendered = presentationRenderer(result.presentationKey, result.data);
|
|
265
265
|
if (rendered != null) {
|
|
266
266
|
return /* @__PURE__ */ jsx3("div", {
|
|
267
|
-
className: "mt-2 rounded-md border
|
|
267
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
268
268
|
children: rendered
|
|
269
269
|
});
|
|
270
270
|
}
|
|
@@ -273,7 +273,7 @@ function ToolResultRenderer({
|
|
|
273
273
|
const rendered = formRenderer(result.formKey, result.defaultValues);
|
|
274
274
|
if (rendered != null) {
|
|
275
275
|
return /* @__PURE__ */ jsx3("div", {
|
|
276
|
-
className: "mt-2 rounded-md border
|
|
276
|
+
className: "border-border bg-background/50 mt-2 rounded-md border p-3",
|
|
277
277
|
children: rendered
|
|
278
278
|
});
|
|
279
279
|
}
|
|
@@ -2147,7 +2147,9 @@ function agentToolConfigsToToolSet(configs, handlers) {
|
|
|
2147
2147
|
// src/core/surface-planner-tools.ts
|
|
2148
2148
|
import { tool as tool3 } from "ai";
|
|
2149
2149
|
import { z as z3 } from "zod";
|
|
2150
|
-
import {
|
|
2150
|
+
import {
|
|
2151
|
+
validatePatchProposal
|
|
2152
|
+
} from "@contractspec/lib.surface-runtime/spec/validate-surface-patch";
|
|
2151
2153
|
import { buildSurfacePatchProposal } from "@contractspec/lib.surface-runtime/runtime/planner-tools";
|
|
2152
2154
|
var VALID_OPS = [
|
|
2153
2155
|
"insert-node",
|
|
@@ -2283,7 +2285,10 @@ function buildPlannerPromptInput(plan) {
|
|
|
2283
2285
|
allowedPatchOps: constraints.allowedOps,
|
|
2284
2286
|
allowedSlots: [...constraints.allowedSlots],
|
|
2285
2287
|
allowedNodeKinds: [...constraints.allowedNodeKinds],
|
|
2286
|
-
actions: plan.actions.map((a) => ({
|
|
2288
|
+
actions: plan.actions.map((a) => ({
|
|
2289
|
+
actionId: a.actionId,
|
|
2290
|
+
title: a.title
|
|
2291
|
+
})),
|
|
2287
2292
|
preferences: {
|
|
2288
2293
|
guidance: "hints",
|
|
2289
2294
|
density: "standard",
|
|
@@ -3055,7 +3060,17 @@ function useChat(options = {}) {
|
|
|
3055
3060
|
setIsLoading(false);
|
|
3056
3061
|
abortControllerRef.current = null;
|
|
3057
3062
|
}
|
|
3058
|
-
}, [
|
|
3063
|
+
}, [
|
|
3064
|
+
conversationId,
|
|
3065
|
+
streaming,
|
|
3066
|
+
onSend,
|
|
3067
|
+
onResponse,
|
|
3068
|
+
onError,
|
|
3069
|
+
onUsage,
|
|
3070
|
+
messages,
|
|
3071
|
+
agentMode,
|
|
3072
|
+
store
|
|
3073
|
+
]);
|
|
3059
3074
|
const clearConversation = React11.useCallback(() => {
|
|
3060
3075
|
setMessages([]);
|
|
3061
3076
|
setConversation(null);
|
|
@@ -3083,7 +3098,9 @@ function useChat(options = {}) {
|
|
|
3083
3098
|
const msg = messages.find((m) => m.id === messageId);
|
|
3084
3099
|
if (!msg || msg.role !== "user")
|
|
3085
3100
|
return;
|
|
3086
|
-
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3101
|
+
await chatServiceRef.current.updateMessage(conversationId, messageId, {
|
|
3102
|
+
content: newContent
|
|
3103
|
+
});
|
|
3087
3104
|
const truncated = await chatServiceRef.current.truncateAfter(conversationId, messageId);
|
|
3088
3105
|
if (truncated) {
|
|
3089
3106
|
setMessages(truncated.messages);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/module.ai-chat",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "AI chat interface module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"typecheck": "tsc --noEmit"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@contractspec/lib.ai-agent": "5.0.
|
|
35
|
-
"@contractspec/lib.surface-runtime": "0.3.
|
|
36
|
-
"@contractspec/lib.ai-providers": "3.5.
|
|
37
|
-
"@contractspec/lib.contracts-spec": "3.5.
|
|
38
|
-
"@contractspec/lib.workflow-composer": "3.5.
|
|
39
|
-
"@contractspec/lib.schema": "3.5.
|
|
40
|
-
"@contractspec/lib.metering": "3.5.
|
|
41
|
-
"@contractspec/lib.cost-tracking": "3.5.
|
|
42
|
-
"@contractspec/lib.design-system": "3.5.
|
|
43
|
-
"@contractspec/lib.ui-kit-web": "3.5.
|
|
34
|
+
"@contractspec/lib.ai-agent": "5.0.2",
|
|
35
|
+
"@contractspec/lib.surface-runtime": "0.3.2",
|
|
36
|
+
"@contractspec/lib.ai-providers": "3.5.2",
|
|
37
|
+
"@contractspec/lib.contracts-spec": "3.5.2",
|
|
38
|
+
"@contractspec/lib.workflow-composer": "3.5.2",
|
|
39
|
+
"@contractspec/lib.schema": "3.5.2",
|
|
40
|
+
"@contractspec/lib.metering": "3.5.2",
|
|
41
|
+
"@contractspec/lib.cost-tracking": "3.5.2",
|
|
42
|
+
"@contractspec/lib.design-system": "3.5.2",
|
|
43
|
+
"@contractspec/lib.ui-kit-web": "3.5.2",
|
|
44
44
|
"@ai-sdk/react": "3.0.118",
|
|
45
45
|
"ai": "6.0.116",
|
|
46
46
|
"lucide-react": "^0.577.0",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"zod": "^4.3.5"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@contractspec/tool.typescript": "3.5.
|
|
51
|
+
"@contractspec/tool.typescript": "3.5.2",
|
|
52
52
|
"@types/react": "^19.2.14",
|
|
53
53
|
"typescript": "^5.9.3",
|
|
54
|
-
"@contractspec/tool.bun": "3.5.
|
|
54
|
+
"@contractspec/tool.bun": "3.5.2"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"react": ">=19.2.4"
|