plugin-agent-orchestrator 1.0.38 → 1.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/client/index.js +1 -1
- package/dist/client-v2/253.9f0537713cee9e6c.js +10 -0
- package/dist/client-v2/418.ce8f5b2b8a229d1d.js +10 -0
- package/dist/client-v2/53.7c29c28043e9112d.js +10 -0
- package/dist/client-v2/794.9bbb8d3a61b2bdf2.js +10 -0
- package/dist/client-v2/993.82778b6fd6db3cb1.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +6 -6
- package/dist/locale/en-US.json +56 -2
- package/dist/locale/vi-VN.json +56 -2
- package/dist/locale/zh-CN.json +56 -2
- package/dist/node_modules/ajv/.tonic_example.js +20 -0
- package/dist/node_modules/ajv/LICENSE +22 -0
- package/dist/node_modules/ajv/dist/ajv.bundle.js +7189 -0
- package/dist/node_modules/ajv/dist/ajv.min.js +3 -0
- package/dist/node_modules/ajv/lib/ajv.d.ts +397 -0
- package/dist/node_modules/ajv/lib/ajv.js +3 -0
- package/dist/node_modules/ajv/lib/cache.js +26 -0
- package/dist/node_modules/ajv/lib/compile/async.js +90 -0
- package/dist/node_modules/ajv/lib/compile/equal.js +5 -0
- package/dist/node_modules/ajv/lib/compile/error_classes.js +34 -0
- package/dist/node_modules/ajv/lib/compile/formats.js +142 -0
- package/dist/node_modules/ajv/lib/compile/index.js +387 -0
- package/dist/node_modules/ajv/lib/compile/resolve.js +270 -0
- package/dist/node_modules/ajv/lib/compile/rules.js +66 -0
- package/dist/node_modules/ajv/lib/compile/schema_obj.js +9 -0
- package/dist/node_modules/ajv/lib/compile/ucs2length.js +20 -0
- package/dist/node_modules/ajv/lib/compile/util.js +239 -0
- package/dist/node_modules/ajv/lib/data.js +49 -0
- package/dist/node_modules/ajv/lib/definition_schema.js +37 -0
- package/dist/node_modules/ajv/lib/dot/_limit.jst +113 -0
- package/dist/node_modules/ajv/lib/dot/_limitItems.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/_limitLength.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/_limitProperties.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/allOf.jst +32 -0
- package/dist/node_modules/ajv/lib/dot/anyOf.jst +46 -0
- package/dist/node_modules/ajv/lib/dot/coerce.def +51 -0
- package/dist/node_modules/ajv/lib/dot/comment.jst +9 -0
- package/dist/node_modules/ajv/lib/dot/const.jst +11 -0
- package/dist/node_modules/ajv/lib/dot/contains.jst +55 -0
- package/dist/node_modules/ajv/lib/dot/custom.jst +191 -0
- package/dist/node_modules/ajv/lib/dot/defaults.def +47 -0
- package/dist/node_modules/ajv/lib/dot/definitions.def +203 -0
- package/dist/node_modules/ajv/lib/dot/dependencies.jst +79 -0
- package/dist/node_modules/ajv/lib/dot/enum.jst +30 -0
- package/dist/node_modules/ajv/lib/dot/errors.def +194 -0
- package/dist/node_modules/ajv/lib/dot/format.jst +106 -0
- package/dist/node_modules/ajv/lib/dot/if.jst +73 -0
- package/dist/node_modules/ajv/lib/dot/items.jst +98 -0
- package/dist/node_modules/ajv/lib/dot/missing.def +39 -0
- package/dist/node_modules/ajv/lib/dot/multipleOf.jst +22 -0
- package/dist/node_modules/ajv/lib/dot/not.jst +43 -0
- package/dist/node_modules/ajv/lib/dot/oneOf.jst +54 -0
- package/dist/node_modules/ajv/lib/dot/pattern.jst +14 -0
- package/dist/node_modules/ajv/lib/dot/properties.jst +245 -0
- package/dist/node_modules/ajv/lib/dot/propertyNames.jst +52 -0
- package/dist/node_modules/ajv/lib/dot/ref.jst +85 -0
- package/dist/node_modules/ajv/lib/dot/required.jst +108 -0
- package/dist/node_modules/ajv/lib/dot/uniqueItems.jst +62 -0
- package/dist/node_modules/ajv/lib/dot/validate.jst +276 -0
- package/dist/node_modules/ajv/lib/dotjs/_limit.js +163 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitItems.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitLength.js +85 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitProperties.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/allOf.js +42 -0
- package/dist/node_modules/ajv/lib/dotjs/anyOf.js +73 -0
- package/dist/node_modules/ajv/lib/dotjs/comment.js +14 -0
- package/dist/node_modules/ajv/lib/dotjs/const.js +56 -0
- package/dist/node_modules/ajv/lib/dotjs/contains.js +81 -0
- package/dist/node_modules/ajv/lib/dotjs/custom.js +228 -0
- package/dist/node_modules/ajv/lib/dotjs/dependencies.js +168 -0
- package/dist/node_modules/ajv/lib/dotjs/enum.js +66 -0
- package/dist/node_modules/ajv/lib/dotjs/format.js +150 -0
- package/dist/node_modules/ajv/lib/dotjs/if.js +103 -0
- package/dist/node_modules/ajv/lib/dotjs/index.js +33 -0
- package/dist/node_modules/ajv/lib/dotjs/items.js +140 -0
- package/dist/node_modules/ajv/lib/dotjs/multipleOf.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/not.js +84 -0
- package/dist/node_modules/ajv/lib/dotjs/oneOf.js +73 -0
- package/dist/node_modules/ajv/lib/dotjs/pattern.js +75 -0
- package/dist/node_modules/ajv/lib/dotjs/properties.js +335 -0
- package/dist/node_modules/ajv/lib/dotjs/propertyNames.js +81 -0
- package/dist/node_modules/ajv/lib/dotjs/ref.js +124 -0
- package/dist/node_modules/ajv/lib/dotjs/required.js +270 -0
- package/dist/node_modules/ajv/lib/dotjs/uniqueItems.js +86 -0
- package/dist/node_modules/ajv/lib/dotjs/validate.js +482 -0
- package/dist/node_modules/ajv/lib/keyword.js +146 -0
- package/dist/node_modules/ajv/lib/refs/data.json +17 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-04.json +149 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-06.json +154 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-07.json +168 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-secure.json +94 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/.eslintrc.yml +27 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/.travis.yml +8 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/index.js +89 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/package.json +43 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/.eslintrc.yml +6 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/fixtures/schema.js +125 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/index.spec.js +171 -0
- package/dist/node_modules/ajv/package.json +1 -0
- package/dist/node_modules/ajv/scripts/.eslintrc.yml +3 -0
- package/dist/node_modules/ajv/scripts/bundle.js +61 -0
- package/dist/node_modules/ajv/scripts/compile-dots.js +73 -0
- package/dist/node_modules/ajv/scripts/info +10 -0
- package/dist/node_modules/ajv/scripts/prepare-tests +12 -0
- package/dist/node_modules/ajv/scripts/publish-built-version +32 -0
- package/dist/node_modules/ajv/scripts/travis-gh-pages +23 -0
- package/dist/server/collections/skill-definitions.js +31 -0
- package/dist/server/collections/skill-executions.js +19 -0
- package/dist/server/collections/skill-registry-installations.js +70 -0
- package/dist/server/migrations/20260621000000-native-policy-profile-defaults.js +0 -3
- package/dist/server/migrations/20260727000000-remove-unused-knowledge-scopes.js +51 -0
- package/dist/server/migrations/20260727010000-backfill-skill-tool-names.js +66 -0
- package/dist/server/plugin.js +107 -2
- package/dist/server/resources/agent-knowledge-insights.js +273 -0
- package/dist/server/services/AgentExecutionContext.js +45 -0
- package/dist/server/services/AgentMemoryContextService.js +57 -19
- package/dist/server/services/CodeValidator.js +1 -0
- package/dist/server/services/ExecutionSpanService.js +10 -2
- package/dist/server/services/InputSchemaValidator.js +83 -0
- package/dist/server/services/NativeSubAgentObserver.js +63 -8
- package/dist/server/services/SandboxRunner.js +6 -2
- package/dist/server/services/SkillAccessService.js +109 -0
- package/dist/server/services/SkillManager.js +2 -0
- package/dist/server/services/SkillRepositoryService.js +70 -0
- package/dist/server/skill-hub/actions/git-import.js +479 -216
- package/dist/server/skill-hub/mcp/McpController.js +8 -5
- package/dist/server/skill-hub/middlewares/git-import-request-method-policy.js +69 -0
- package/dist/server/skill-hub/plugin.js +68 -14
- package/dist/server/skill-hub/services/RegistrySkillInstallationService.js +249 -0
- package/dist/server/skill-hub/services/RegistrySkillSnapshotService.js +228 -0
- package/dist/server/skill-hub/tasks/SkillExecutionTask.js +15 -3
- package/dist/server/tools/external-rag-search.js +152 -12
- package/dist/server/tools/skill-execute.js +23 -2
- package/dist/server/utils/ctx-utils.js +2 -2
- package/dist/server/utils/skill-tool-name.js +73 -0
- package/package.json +9 -3
- package/src/client-v2/components/AgentBindingsTab.tsx +269 -0
- package/src/client-v2/components/HarnessProfilesTab.tsx +1 -2
- package/src/client-v2/components/KnowledgeAccessTab.tsx +116 -0
- package/src/client-v2/components/MemoryInspectorTab.tsx +125 -0
- package/src/client-v2/components/RetrievalTraceTab.tsx +162 -0
- package/src/client-v2/pages/AgentBindingsPage.tsx +13 -0
- package/src/client-v2/pages/KnowledgeAccessPage.tsx +10 -0
- package/src/client-v2/pages/MemoryInspectorPage.tsx +13 -0
- package/src/client-v2/pages/RetrievalTracePage.tsx +10 -0
- package/src/client-v2/plugin.tsx +28 -0
- package/src/locale/en-US.json +56 -2
- package/src/locale/vi-VN.json +56 -2
- package/src/locale/zh-CN.json +56 -2
- package/src/server/__tests__/agent-execution-context.test.ts +18 -0
- package/src/server/__tests__/agent-knowledge-insights.test.ts +123 -0
- package/src/server/__tests__/external-rag-search.test.ts +107 -0
- package/src/server/__tests__/input-schema-validator.test.ts +26 -0
- package/src/server/__tests__/native-sub-agent-observer.test.ts +141 -9
- package/src/server/__tests__/skill-access-service.test.ts +64 -0
- package/src/server/__tests__/skill-execute.test.ts +37 -0
- package/src/server/__tests__/skill-tool-name.test.ts +23 -0
- package/src/server/collections/skill-definitions.ts +31 -0
- package/src/server/collections/skill-executions.ts +19 -0
- package/src/server/collections/skill-registry-installations.ts +41 -0
- package/src/server/migrations/20260621000000-native-policy-profile-defaults.ts +0 -3
- package/src/server/migrations/20260727000000-remove-unused-knowledge-scopes.ts +25 -0
- package/src/server/migrations/20260727010000-backfill-skill-tool-names.ts +45 -0
- package/src/server/plugin.ts +107 -1
- package/src/server/resources/agent-knowledge-insights.ts +304 -0
- package/src/server/services/AgentExecutionContext.ts +23 -0
- package/src/server/services/AgentMemoryContextService.ts +63 -19
- package/src/server/services/CodeValidator.ts +1 -0
- package/src/server/services/ExecutionSpanService.ts +119 -110
- package/src/server/services/InputSchemaValidator.ts +44 -0
- package/src/server/services/NativeSubAgentObserver.ts +592 -528
- package/src/server/services/SandboxRunner.ts +6 -0
- package/src/server/services/SkillAccessService.ts +100 -0
- package/src/server/services/SkillManager.ts +2 -0
- package/src/server/services/SkillRepositoryService.ts +98 -2
- package/src/server/services/__tests__/SkillRepositoryService.test.ts +33 -0
- package/src/server/skill-hub/actions/__tests__/git-import.test.ts +501 -0
- package/src/server/skill-hub/actions/git-import.ts +682 -236
- package/src/server/skill-hub/mcp/McpController.ts +8 -14
- package/src/server/skill-hub/middlewares/git-import-request-method-policy.ts +51 -0
- package/src/server/skill-hub/plugin.ts +79 -13
- package/src/server/skill-hub/services/RegistrySkillInstallationService.ts +281 -0
- package/src/server/skill-hub/services/RegistrySkillSnapshotService.ts +239 -0
- package/src/server/skill-hub/services/__tests__/RegistrySkillInstallationService.test.ts +295 -0
- package/src/server/skill-hub/services/__tests__/RegistrySkillSnapshotService.test.ts +63 -0
- package/src/server/skill-hub/tasks/SkillExecutionTask.ts +14 -2
- package/src/server/tools/external-rag-search.ts +215 -14
- package/src/server/tools/skill-execute.ts +24 -2
- package/src/server/utils/ctx-utils.ts +1 -1
- package/src/server/utils/skill-tool-name.ts +58 -0
- package/dist/client-v2/418.29e713f79131eece.js +0 -10
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
|
+
import { Button, Card, Drawer, Empty, Space, Table, Tag, Typography } from 'antd';
|
|
3
|
+
import { EyeOutlined, ReloadOutlined } from '@ant-design/icons';
|
|
4
|
+
import { useRequest } from '../hooks/useApiRequest';
|
|
5
|
+
import { useT } from '../skill-hub/locale';
|
|
6
|
+
|
|
7
|
+
type Citation = {
|
|
8
|
+
knowledgeBaseId?: string;
|
|
9
|
+
knowledgeBaseName?: string;
|
|
10
|
+
sourceId?: string;
|
|
11
|
+
filename?: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
collection?: string;
|
|
14
|
+
recordId?: string;
|
|
15
|
+
excerpt?: string;
|
|
16
|
+
score?: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type RetrievalRow = {
|
|
20
|
+
id: string | number;
|
|
21
|
+
createdAt?: string;
|
|
22
|
+
employeeUsername?: string;
|
|
23
|
+
leaderUsername?: string;
|
|
24
|
+
query?: string;
|
|
25
|
+
decision: 'allowed' | 'denied';
|
|
26
|
+
reason: string;
|
|
27
|
+
citations: Citation[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function responseRows(value: unknown): RetrievalRow[] {
|
|
31
|
+
const body = value as { data?: unknown } | undefined;
|
|
32
|
+
return Array.isArray(body?.data) ? (body.data as RetrievalRow[]) : [];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const RetrievalTraceTab: React.FC = () => {
|
|
36
|
+
const t = useT();
|
|
37
|
+
const [selected, setSelected] = useState<RetrievalRow | null>(null);
|
|
38
|
+
const request = useRequest({
|
|
39
|
+
url: 'agentKnowledgeInsights:retrievalTrace',
|
|
40
|
+
params: { page: 1, pageSize: 100 },
|
|
41
|
+
});
|
|
42
|
+
const rows = useMemo(() => responseRows(request.data), [request.data]);
|
|
43
|
+
|
|
44
|
+
const columns = [
|
|
45
|
+
{
|
|
46
|
+
title: t('Time'),
|
|
47
|
+
dataIndex: 'createdAt',
|
|
48
|
+
key: 'createdAt',
|
|
49
|
+
width: 180,
|
|
50
|
+
render: (value?: string) => (value ? new Date(value).toLocaleString() : '-'),
|
|
51
|
+
},
|
|
52
|
+
{ title: t('AI Employee'), dataIndex: 'employeeUsername', key: 'employeeUsername', width: 160 },
|
|
53
|
+
{
|
|
54
|
+
title: t('Query'),
|
|
55
|
+
dataIndex: 'query',
|
|
56
|
+
key: 'query',
|
|
57
|
+
render: (query?: string) => (
|
|
58
|
+
<Typography.Paragraph ellipsis={{ rows: 2 }} style={{ margin: 0, maxWidth: 360 }}>
|
|
59
|
+
{query || '-'}
|
|
60
|
+
</Typography.Paragraph>
|
|
61
|
+
),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: t('Decision'),
|
|
65
|
+
dataIndex: 'decision',
|
|
66
|
+
key: 'decision',
|
|
67
|
+
width: 110,
|
|
68
|
+
render: (decision: RetrievalRow['decision']) => (
|
|
69
|
+
<Tag color={decision === 'allowed' ? 'success' : 'error'}>
|
|
70
|
+
{decision === 'allowed' ? t('Allowed') : t('Denied')}
|
|
71
|
+
</Tag>
|
|
72
|
+
),
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
title: t('Citations'),
|
|
76
|
+
dataIndex: 'citations',
|
|
77
|
+
key: 'citations',
|
|
78
|
+
width: 100,
|
|
79
|
+
render: (citations: Citation[]) => citations?.length || 0,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
title: t('Actions'),
|
|
83
|
+
key: 'actions',
|
|
84
|
+
width: 100,
|
|
85
|
+
render: (_: unknown, row: RetrievalRow) => (
|
|
86
|
+
<Button type="link" size="small" icon={<EyeOutlined />} onClick={() => setSelected(row)}>
|
|
87
|
+
{t('Detail')}
|
|
88
|
+
</Button>
|
|
89
|
+
),
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Card bordered={false}>
|
|
95
|
+
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
|
96
|
+
<Typography.Text type="secondary">
|
|
97
|
+
{t(
|
|
98
|
+
'Retrieval trace stores the decision, query, and safe source citations. It does not repeat raw RAG provider metadata.',
|
|
99
|
+
)}
|
|
100
|
+
</Typography.Text>
|
|
101
|
+
<Button icon={<ReloadOutlined />} onClick={request.refresh} style={{ alignSelf: 'flex-start' }}>
|
|
102
|
+
{t('Refresh')}
|
|
103
|
+
</Button>
|
|
104
|
+
<Table
|
|
105
|
+
rowKey="id"
|
|
106
|
+
loading={request.loading}
|
|
107
|
+
dataSource={rows}
|
|
108
|
+
columns={columns}
|
|
109
|
+
scroll={{ x: 'max-content' }}
|
|
110
|
+
pagination={{ pageSize: 50, showSizeChanger: true }}
|
|
111
|
+
/>
|
|
112
|
+
</Space>
|
|
113
|
+
<Drawer title={t('Retrieval detail')} open={Boolean(selected)} onClose={() => setSelected(null)} width={760}>
|
|
114
|
+
{selected && (
|
|
115
|
+
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
|
116
|
+
<Typography.Text strong>{t('Decision')}</Typography.Text>
|
|
117
|
+
<Tag color={selected.decision === 'allowed' ? 'success' : 'error'}>{selected.decision}</Tag>
|
|
118
|
+
<Typography.Paragraph>
|
|
119
|
+
<Typography.Text strong>{t('Reason')}: </Typography.Text>
|
|
120
|
+
{selected.reason}
|
|
121
|
+
</Typography.Paragraph>
|
|
122
|
+
<Typography.Paragraph>
|
|
123
|
+
<Typography.Text strong>{t('Query')}: </Typography.Text>
|
|
124
|
+
{selected.query || '-'}
|
|
125
|
+
</Typography.Paragraph>
|
|
126
|
+
<Card title={t('Citations')} size="small">
|
|
127
|
+
{selected.citations.length ? (
|
|
128
|
+
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
|
129
|
+
{selected.citations.map((citation, index) => (
|
|
130
|
+
<Card key={`${citation.sourceId || citation.filename || index}`} size="small">
|
|
131
|
+
<Space direction="vertical" size={4} style={{ width: '100%' }}>
|
|
132
|
+
<Typography.Text strong>
|
|
133
|
+
{citation.filename || citation.sourceId || t('Unknown source')}
|
|
134
|
+
</Typography.Text>
|
|
135
|
+
<Typography.Text type="secondary">
|
|
136
|
+
{citation.knowledgeBaseName || citation.knowledgeBaseId || '-'}
|
|
137
|
+
{citation.score != null ? ` · ${citation.score.toFixed(3)}` : ''}
|
|
138
|
+
</Typography.Text>
|
|
139
|
+
{citation.url ? (
|
|
140
|
+
<Typography.Link href={citation.url} target="_blank" rel="noreferrer">
|
|
141
|
+
{citation.url}
|
|
142
|
+
</Typography.Link>
|
|
143
|
+
) : null}
|
|
144
|
+
{citation.excerpt ? (
|
|
145
|
+
<Typography.Paragraph style={{ whiteSpace: 'pre-wrap', margin: 0 }}>
|
|
146
|
+
{citation.excerpt}
|
|
147
|
+
</Typography.Paragraph>
|
|
148
|
+
) : null}
|
|
149
|
+
</Space>
|
|
150
|
+
</Card>
|
|
151
|
+
))}
|
|
152
|
+
</Space>
|
|
153
|
+
) : (
|
|
154
|
+
<Empty description={t('No citations were returned')} />
|
|
155
|
+
)}
|
|
156
|
+
</Card>
|
|
157
|
+
</Space>
|
|
158
|
+
)}
|
|
159
|
+
</Drawer>
|
|
160
|
+
</Card>
|
|
161
|
+
);
|
|
162
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AIEmployeesProvider } from '../components/AIEmployeesContext';
|
|
3
|
+
import { AgentBindingsTab } from '../components/AgentBindingsTab';
|
|
4
|
+
|
|
5
|
+
const AgentBindingsPage: React.FC = () => (
|
|
6
|
+
<AIEmployeesProvider>
|
|
7
|
+
<div style={{ padding: '0 24px 24px' }}>
|
|
8
|
+
<AgentBindingsTab />
|
|
9
|
+
</div>
|
|
10
|
+
</AIEmployeesProvider>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export default AgentBindingsPage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { KnowledgeAccessTab } from '../components/KnowledgeAccessTab';
|
|
3
|
+
|
|
4
|
+
const KnowledgeAccessPage: React.FC = () => (
|
|
5
|
+
<div style={{ padding: '0 24px 24px' }}>
|
|
6
|
+
<KnowledgeAccessTab />
|
|
7
|
+
</div>
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export default KnowledgeAccessPage;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AIEmployeesProvider } from '../components/AIEmployeesContext';
|
|
3
|
+
import { MemoryInspectorTab } from '../components/MemoryInspectorTab';
|
|
4
|
+
|
|
5
|
+
const MemoryInspectorPage: React.FC = () => (
|
|
6
|
+
<AIEmployeesProvider>
|
|
7
|
+
<div style={{ padding: '0 24px 24px' }}>
|
|
8
|
+
<MemoryInspectorTab />
|
|
9
|
+
</div>
|
|
10
|
+
</AIEmployeesProvider>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export default MemoryInspectorPage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RetrievalTraceTab } from '../components/RetrievalTraceTab';
|
|
3
|
+
|
|
4
|
+
const RetrievalTracePage: React.FC = () => (
|
|
5
|
+
<div style={{ padding: '0 24px 24px' }}>
|
|
6
|
+
<RetrievalTraceTab />
|
|
7
|
+
</div>
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export default RetrievalTracePage;
|
package/src/client-v2/plugin.tsx
CHANGED
|
@@ -37,6 +37,34 @@ export class PluginAgentOrchestratorClient extends Plugin<Record<string, never>,
|
|
|
37
37
|
componentLoader: () => import('./pages/HarnessProfilesPage'),
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
this.pluginSettingsManager.addPageTabItem({
|
|
41
|
+
menuKey: 'ai.orchestrator',
|
|
42
|
+
key: 'agent-bindings',
|
|
43
|
+
title: this.t('Agent Bindings'),
|
|
44
|
+
componentLoader: () => import('./pages/AgentBindingsPage'),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
this.pluginSettingsManager.addPageTabItem({
|
|
48
|
+
menuKey: 'ai.orchestrator',
|
|
49
|
+
key: 'knowledge-access',
|
|
50
|
+
title: this.t('Knowledge Access'),
|
|
51
|
+
componentLoader: () => import('./pages/KnowledgeAccessPage'),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
this.pluginSettingsManager.addPageTabItem({
|
|
55
|
+
menuKey: 'ai.orchestrator',
|
|
56
|
+
key: 'retrieval-trace',
|
|
57
|
+
title: this.t('Retrieval Trace'),
|
|
58
|
+
componentLoader: () => import('./pages/RetrievalTracePage'),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
this.pluginSettingsManager.addPageTabItem({
|
|
62
|
+
menuKey: 'ai.orchestrator',
|
|
63
|
+
key: 'memory-inspector',
|
|
64
|
+
title: this.t('Memory Inspector'),
|
|
65
|
+
componentLoader: () => import('./pages/MemoryInspectorPage'),
|
|
66
|
+
});
|
|
67
|
+
|
|
40
68
|
this.pluginSettingsManager.addPageTabItem({
|
|
41
69
|
menuKey: 'ai.orchestrator',
|
|
42
70
|
key: 'skill-definitions',
|
package/src/locale/en-US.json
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"Edit": "Edit",
|
|
76
76
|
"Delete this profile?": "Delete this profile?",
|
|
77
77
|
"Delete": "Delete",
|
|
78
|
-
"Policy profiles control native
|
|
78
|
+
"Policy profiles control native observation, memory scopes, and tracing retention.": "Policy profiles control native observation, memory scopes, and tracing retention.",
|
|
79
79
|
"New Policy": "New Policy",
|
|
80
80
|
"Edit Policy Profile": "Edit Policy Profile",
|
|
81
81
|
"New Policy Profile": "New Policy Profile",
|
|
@@ -92,5 +92,59 @@
|
|
|
92
92
|
"Save failed: {{message}}": "Save failed: {{message}}",
|
|
93
93
|
"Policy profile deleted": "Policy profile deleted",
|
|
94
94
|
"Delete failed: {{message}}": "Delete failed: {{message}}",
|
|
95
|
-
"unknown error": "unknown error"
|
|
95
|
+
"unknown error": "unknown error",
|
|
96
|
+
"Agent Bindings": "Agent Bindings",
|
|
97
|
+
"Knowledge Access": "Knowledge Access",
|
|
98
|
+
"Retrieval Trace": "Retrieval Trace",
|
|
99
|
+
"Memory Inspector": "Memory Inspector",
|
|
100
|
+
"Policy Profile": "Policy Profile",
|
|
101
|
+
"Agent binding updated": "Agent binding updated",
|
|
102
|
+
"Agent binding created": "Agent binding created",
|
|
103
|
+
"Agent binding deleted": "Agent binding deleted",
|
|
104
|
+
"Delete this binding?": "Delete this binding?",
|
|
105
|
+
"Bind each leader/sub-agent pair to the profile that controls memory and tracing policy.": "Bind each leader/sub-agent pair to the profile that controls memory and tracing policy.",
|
|
106
|
+
"New Agent Binding": "New Agent Binding",
|
|
107
|
+
"Edit Agent Binding": "Edit Agent Binding",
|
|
108
|
+
"Leader is required": "Leader is required",
|
|
109
|
+
"Sub-agent is required": "Sub-agent is required",
|
|
110
|
+
"Policy profile is required": "Policy profile is required",
|
|
111
|
+
"Select leader": "Select leader",
|
|
112
|
+
"Select sub-agent": "Select sub-agent",
|
|
113
|
+
"Select policy profile": "Select policy profile",
|
|
114
|
+
"AI Employee": "AI Employee",
|
|
115
|
+
"Knowledge Base": "Knowledge Base",
|
|
116
|
+
"Assignment": "Assignment",
|
|
117
|
+
"Assigned": "Assigned",
|
|
118
|
+
"Not assigned": "Not assigned",
|
|
119
|
+
"Agent access": "Agent access",
|
|
120
|
+
"Allowed": "Allowed",
|
|
121
|
+
"Denied": "Denied",
|
|
122
|
+
"Reason": "Reason",
|
|
123
|
+
"Runtime user gate": "Runtime user gate",
|
|
124
|
+
"This matrix checks employee assignment and static agent policy. BASIC and SHARED user access is still evaluated when a run starts.": "This matrix checks employee assignment and static agent policy. BASIC and SHARED user access is still evaluated when a run starts.",
|
|
125
|
+
"Show all": "Show all",
|
|
126
|
+
"Show denied only": "Show denied only",
|
|
127
|
+
"Decision": "Decision",
|
|
128
|
+
"Citations": "Citations",
|
|
129
|
+
"Retrieval trace stores the decision, query, and safe source citations. It does not repeat raw RAG provider metadata.": "Retrieval trace stores the decision, query, and safe source citations. It does not repeat raw RAG provider metadata.",
|
|
130
|
+
"Retrieval detail": "Retrieval detail",
|
|
131
|
+
"Unknown source": "Unknown source",
|
|
132
|
+
"No citations were returned": "No citations were returned",
|
|
133
|
+
"Memory preview returned no data": "Memory preview returned no data",
|
|
134
|
+
"Memory preview failed": "Memory preview failed",
|
|
135
|
+
"Preview the exact memory context for a user and selected sub-agent before a run. Memory is marked as data, not executable instructions.": "Preview the exact memory context for a user and selected sub-agent before a run. Memory is marked as data, not executable instructions.",
|
|
136
|
+
"User ID": "User ID",
|
|
137
|
+
"User ID is required": "User ID is required",
|
|
138
|
+
"Build memory preview": "Build memory preview",
|
|
139
|
+
"Final memory context": "Final memory context",
|
|
140
|
+
"Character budget": "Character budget",
|
|
141
|
+
"Applied scopes": "Applied scopes",
|
|
142
|
+
"None": "None",
|
|
143
|
+
"No memory context matched this preview.": "No memory context matched this preview.",
|
|
144
|
+
"This Skill Hub Git import action does not allow the request method.": "This Skill Hub Git import action does not allow the request method.",
|
|
145
|
+
"skills[] must contain non-empty string keys": "skills[] must contain non-empty string keys",
|
|
146
|
+
"Selected skills are not listed in the explicit skills.json manifest: {{skills}}": "Selected skills are not listed in the explicit skills.json manifest: {{skills}}",
|
|
147
|
+
"Git skill contains more than {{count}} supplemental Markdown files.": "Git skill contains more than {{count}} supplemental Markdown files.",
|
|
148
|
+
"Git skill contains a supplemental Markdown file with an invalid size.": "Git skill contains a supplemental Markdown file with an invalid size.",
|
|
149
|
+
"Git skill supplemental Markdown exceeds {{maxBytes}} bytes.": "Git skill supplemental Markdown exceeds {{maxBytes}} bytes."
|
|
96
150
|
}
|
package/src/locale/vi-VN.json
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"Edit": "Sửa",
|
|
76
76
|
"Delete this profile?": "Xóa hồ sơ này?",
|
|
77
77
|
"Delete": "Xóa",
|
|
78
|
-
"Policy profiles control native
|
|
78
|
+
"Policy profiles control native observation, memory scopes, and tracing retention.": "Hồ sơ chính sách kiểm soát quan sát native, phạm vi bộ nhớ và thời gian lưu trace.",
|
|
79
79
|
"New Policy": "Chính sách mới",
|
|
80
80
|
"Edit Policy Profile": "Sửa hồ sơ chính sách",
|
|
81
81
|
"New Policy Profile": "Hồ sơ chính sách mới",
|
|
@@ -92,5 +92,59 @@
|
|
|
92
92
|
"Save failed: {{message}}": "Lưu thất bại: {{message}}",
|
|
93
93
|
"Policy profile deleted": "Đã xóa hồ sơ chính sách",
|
|
94
94
|
"Delete failed: {{message}}": "Xóa thất bại: {{message}}",
|
|
95
|
-
"unknown error": "lỗi không xác định"
|
|
95
|
+
"unknown error": "lỗi không xác định",
|
|
96
|
+
"Agent Bindings": "Liên kết Agent",
|
|
97
|
+
"Knowledge Access": "Quyền truy cập Knowledge Base",
|
|
98
|
+
"Retrieval Trace": "Dấu vết truy xuất",
|
|
99
|
+
"Memory Inspector": "Kiểm tra bộ nhớ",
|
|
100
|
+
"Policy Profile": "Hồ sơ chính sách",
|
|
101
|
+
"Agent binding updated": "Đã cập nhật liên kết agent",
|
|
102
|
+
"Agent binding created": "Đã tạo liên kết agent",
|
|
103
|
+
"Agent binding deleted": "Đã xóa liên kết agent",
|
|
104
|
+
"Delete this binding?": "Xóa liên kết này?",
|
|
105
|
+
"Bind each leader/sub-agent pair to the profile that controls memory and tracing policy.": "Liên kết từng cặp leader/agent con với hồ sơ kiểm soát bộ nhớ và truy vết.",
|
|
106
|
+
"New Agent Binding": "Liên kết agent mới",
|
|
107
|
+
"Edit Agent Binding": "Sửa liên kết agent",
|
|
108
|
+
"Leader is required": "Bắt buộc chọn leader",
|
|
109
|
+
"Sub-agent is required": "Bắt buộc chọn agent con",
|
|
110
|
+
"Policy profile is required": "Bắt buộc chọn hồ sơ chính sách",
|
|
111
|
+
"Select leader": "Chọn leader",
|
|
112
|
+
"Select sub-agent": "Chọn agent con",
|
|
113
|
+
"Select policy profile": "Chọn hồ sơ chính sách",
|
|
114
|
+
"AI Employee": "AI Employee",
|
|
115
|
+
"Knowledge Base": "Knowledge Base",
|
|
116
|
+
"Assignment": "Gán KB",
|
|
117
|
+
"Assigned": "Đã gán",
|
|
118
|
+
"Not assigned": "Chưa gán",
|
|
119
|
+
"Agent access": "Quyền của agent",
|
|
120
|
+
"Allowed": "Được phép",
|
|
121
|
+
"Denied": "Bị từ chối",
|
|
122
|
+
"Reason": "Lý do",
|
|
123
|
+
"Runtime user gate": "Điều kiện người dùng khi chạy",
|
|
124
|
+
"This matrix checks employee assignment and static agent policy. BASIC and SHARED user access is still evaluated when a run starts.": "Ma trận kiểm tra KB được gán cho nhân viên và chính sách agent tĩnh. Quyền BASIC và SHARED của người dùng vẫn được kiểm tra khi lượt chạy bắt đầu.",
|
|
125
|
+
"Show all": "Hiện tất cả",
|
|
126
|
+
"Show denied only": "Chỉ hiện bị từ chối",
|
|
127
|
+
"Decision": "Quyết định",
|
|
128
|
+
"Citations": "Nguồn trích dẫn",
|
|
129
|
+
"Retrieval trace stores the decision, query, and safe source citations. It does not repeat raw RAG provider metadata.": "Dấu vết truy xuất lưu quyết định, truy vấn và nguồn trích dẫn an toàn; không lặp lại metadata thô của nhà cung cấp RAG.",
|
|
130
|
+
"Retrieval detail": "Chi tiết truy xuất",
|
|
131
|
+
"Unknown source": "Nguồn không xác định",
|
|
132
|
+
"No citations were returned": "Không có nguồn trích dẫn được trả về",
|
|
133
|
+
"Memory preview returned no data": "Bản xem trước bộ nhớ không trả dữ liệu",
|
|
134
|
+
"Memory preview failed": "Tạo bản xem trước bộ nhớ thất bại",
|
|
135
|
+
"Preview the exact memory context for a user and selected sub-agent before a run. Memory is marked as data, not executable instructions.": "Xem trước đúng context bộ nhớ cho người dùng và agent con trước khi chạy. Bộ nhớ được đánh dấu là dữ liệu, không phải chỉ dẫn có thể thực thi.",
|
|
136
|
+
"User ID": "ID người dùng",
|
|
137
|
+
"User ID is required": "Bắt buộc nhập ID người dùng",
|
|
138
|
+
"Build memory preview": "Tạo xem trước bộ nhớ",
|
|
139
|
+
"Final memory context": "Context bộ nhớ cuối cùng",
|
|
140
|
+
"Character budget": "Ngân sách ký tự",
|
|
141
|
+
"Applied scopes": "Phạm vi đã áp dụng",
|
|
142
|
+
"None": "Không có",
|
|
143
|
+
"No memory context matched this preview.": "Không có context bộ nhớ phù hợp với bản xem trước này.",
|
|
144
|
+
"This Skill Hub Git import action does not allow the request method.": "Thao tác nhập Git của Skill Hub không cho phép phương thức yêu cầu này.",
|
|
145
|
+
"skills[] must contain non-empty string keys": "skills[] chỉ được chứa các khóa chuỗi không rỗng.",
|
|
146
|
+
"Selected skills are not listed in the explicit skills.json manifest: {{skills}}": "Các skill được chọn không có trong manifest skills.json tường minh: {{skills}}",
|
|
147
|
+
"Git skill contains more than {{count}} supplemental Markdown files.": "Skill Git chứa hơn {{count}} tệp Markdown bổ sung.",
|
|
148
|
+
"Git skill contains a supplemental Markdown file with an invalid size.": "Skill Git có một tệp Markdown bổ sung với kích thước không hợp lệ.",
|
|
149
|
+
"Git skill supplemental Markdown exceeds {{maxBytes}} bytes.": "Markdown bổ sung của skill Git vượt quá {{maxBytes}} byte."
|
|
96
150
|
}
|
package/src/locale/zh-CN.json
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"Edit": "编辑",
|
|
76
76
|
"Delete this profile?": "删除此配置?",
|
|
77
77
|
"Delete": "删除",
|
|
78
|
-
"Policy profiles control native
|
|
78
|
+
"Policy profiles control native observation, memory scopes, and tracing retention.": "策略配置控制原生观测、记忆范围和追踪保留时间。",
|
|
79
79
|
"New Policy": "新建策略",
|
|
80
80
|
"Edit Policy Profile": "编辑策略配置",
|
|
81
81
|
"New Policy Profile": "新建策略配置",
|
|
@@ -92,5 +92,59 @@
|
|
|
92
92
|
"Save failed: {{message}}": "保存失败:{{message}}",
|
|
93
93
|
"Policy profile deleted": "策略配置已删除",
|
|
94
94
|
"Delete failed: {{message}}": "删除失败:{{message}}",
|
|
95
|
-
"unknown error": "未知错误"
|
|
95
|
+
"unknown error": "未知错误",
|
|
96
|
+
"Agent Bindings": "智能体绑定",
|
|
97
|
+
"Knowledge Access": "知识库访问",
|
|
98
|
+
"Retrieval Trace": "检索追踪",
|
|
99
|
+
"Memory Inspector": "记忆检查器",
|
|
100
|
+
"Policy Profile": "策略配置",
|
|
101
|
+
"Agent binding updated": "智能体绑定已更新",
|
|
102
|
+
"Agent binding created": "智能体绑定已创建",
|
|
103
|
+
"Agent binding deleted": "智能体绑定已删除",
|
|
104
|
+
"Delete this binding?": "删除此绑定?",
|
|
105
|
+
"Bind each leader/sub-agent pair to the profile that controls memory and tracing policy.": "将每个主控/子智能体组合绑定到控制记忆和追踪策略的配置。",
|
|
106
|
+
"New Agent Binding": "新建智能体绑定",
|
|
107
|
+
"Edit Agent Binding": "编辑智能体绑定",
|
|
108
|
+
"Leader is required": "必须选择主控",
|
|
109
|
+
"Sub-agent is required": "必须选择子智能体",
|
|
110
|
+
"Policy profile is required": "必须选择策略配置",
|
|
111
|
+
"Select leader": "选择主控",
|
|
112
|
+
"Select sub-agent": "选择子智能体",
|
|
113
|
+
"Select policy profile": "选择策略配置",
|
|
114
|
+
"AI Employee": "AI 员工",
|
|
115
|
+
"Knowledge Base": "知识库",
|
|
116
|
+
"Assignment": "分配",
|
|
117
|
+
"Assigned": "已分配",
|
|
118
|
+
"Not assigned": "未分配",
|
|
119
|
+
"Agent access": "智能体访问",
|
|
120
|
+
"Allowed": "允许",
|
|
121
|
+
"Denied": "拒绝",
|
|
122
|
+
"Reason": "原因",
|
|
123
|
+
"Runtime user gate": "运行时用户条件",
|
|
124
|
+
"This matrix checks employee assignment and static agent policy. BASIC and SHARED user access is still evaluated when a run starts.": "此矩阵检查员工分配和静态智能体策略。BASIC 和 SHARED 用户访问权限仍会在运行开始时检查。",
|
|
125
|
+
"Show all": "显示全部",
|
|
126
|
+
"Show denied only": "仅显示拒绝项",
|
|
127
|
+
"Decision": "决定",
|
|
128
|
+
"Citations": "引用来源",
|
|
129
|
+
"Retrieval trace stores the decision, query, and safe source citations. It does not repeat raw RAG provider metadata.": "检索追踪保存决定、查询和安全的来源引用,不重复保存原始 RAG 提供方元数据。",
|
|
130
|
+
"Retrieval detail": "检索详情",
|
|
131
|
+
"Unknown source": "未知来源",
|
|
132
|
+
"No citations were returned": "未返回引用来源",
|
|
133
|
+
"Memory preview returned no data": "记忆预览没有返回数据",
|
|
134
|
+
"Memory preview failed": "记忆预览失败",
|
|
135
|
+
"Preview the exact memory context for a user and selected sub-agent before a run. Memory is marked as data, not executable instructions.": "在运行前预览用户和所选子智能体的准确记忆上下文。记忆被标记为数据,而非可执行指令。",
|
|
136
|
+
"User ID": "用户 ID",
|
|
137
|
+
"User ID is required": "必须填写用户 ID",
|
|
138
|
+
"Build memory preview": "生成记忆预览",
|
|
139
|
+
"Final memory context": "最终记忆上下文",
|
|
140
|
+
"Character budget": "字符预算",
|
|
141
|
+
"Applied scopes": "已应用范围",
|
|
142
|
+
"None": "无",
|
|
143
|
+
"No memory context matched this preview.": "没有匹配此预览的记忆上下文。",
|
|
144
|
+
"This Skill Hub Git import action does not allow the request method.": "此 Skill Hub Git 导入操作不允许该请求方法。",
|
|
145
|
+
"skills[] must contain non-empty string keys": "skills[] 必须只包含非空字符串键。",
|
|
146
|
+
"Selected skills are not listed in the explicit skills.json manifest: {{skills}}": "所选技能不在显式 skills.json 清单中:{{skills}}",
|
|
147
|
+
"Git skill contains more than {{count}} supplemental Markdown files.": "Git 技能包含超过 {{count}} 个补充 Markdown 文件。",
|
|
148
|
+
"Git skill contains a supplemental Markdown file with an invalid size.": "Git 技能包含大小无效的补充 Markdown 文件。",
|
|
149
|
+
"Git skill supplemental Markdown exceeds {{maxBytes}} bytes.": "Git 技能的补充 Markdown 超过 {{maxBytes}} 字节。"
|
|
96
150
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { getAgentExecutionContext, runWithAgentExecutionContext } from '../services/AgentExecutionContext';
|
|
3
|
+
|
|
4
|
+
describe('AgentExecutionContext', () => {
|
|
5
|
+
it('keeps concurrent agent identities isolated across async work', async () => {
|
|
6
|
+
const readIdentity = (employeeUsername: string, delay: number) =>
|
|
7
|
+
runWithAgentExecutionContext({ employeeUsername }, async () => {
|
|
8
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
9
|
+
return getAgentExecutionContext()?.employeeUsername;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
await expect(Promise.all([readIdentity('ocr-agent', 5), readIdentity('report-agent', 1)])).resolves.toEqual([
|
|
13
|
+
'ocr-agent',
|
|
14
|
+
'report-agent',
|
|
15
|
+
]);
|
|
16
|
+
expect(getAgentExecutionContext()).toBeUndefined();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { buildKnowledgeAccessMatrix, summarizeRetrievalSpan } from '../resources/agent-knowledge-insights';
|
|
3
|
+
|
|
4
|
+
describe('agent knowledge insights', () => {
|
|
5
|
+
it('explains assignment and explicit agent-policy decisions per employee and knowledge base', () => {
|
|
6
|
+
const matrix = buildKnowledgeAccessMatrix(
|
|
7
|
+
[
|
|
8
|
+
{
|
|
9
|
+
username: 'researcher',
|
|
10
|
+
knowledgeBase: { knowledgeBaseKeys: ['kb-public', 'kb-explicit'] },
|
|
11
|
+
roles: [{ name: 'research' }],
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
{ id: 'kb-public', name: 'Public docs', enabled: true, agentAccess: 'inherit', accessLevel: 'PUBLIC' },
|
|
16
|
+
{
|
|
17
|
+
id: 'kb-explicit',
|
|
18
|
+
name: 'Restricted docs',
|
|
19
|
+
enabled: true,
|
|
20
|
+
agentAccess: 'explicit',
|
|
21
|
+
allowedRoles: ['research'],
|
|
22
|
+
accessLevel: 'SHARED',
|
|
23
|
+
},
|
|
24
|
+
{ id: 'kb-unassigned', name: 'Unassigned docs', enabled: true, agentAccess: 'inherit' },
|
|
25
|
+
{ id: 'kb-disabled', name: 'Disabled docs', enabled: false, agentAccess: 'inherit' },
|
|
26
|
+
],
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(matrix).toEqual(
|
|
30
|
+
expect.arrayContaining([
|
|
31
|
+
expect.objectContaining({ knowledgeBaseId: 'kb-public', access: 'allowed', assigned: true }),
|
|
32
|
+
expect.objectContaining({
|
|
33
|
+
knowledgeBaseId: 'kb-explicit',
|
|
34
|
+
access: 'allowed',
|
|
35
|
+
reason: expect.stringContaining('role'),
|
|
36
|
+
}),
|
|
37
|
+
expect.objectContaining({
|
|
38
|
+
knowledgeBaseId: 'kb-unassigned',
|
|
39
|
+
access: 'denied',
|
|
40
|
+
reason: expect.stringContaining('not assigned'),
|
|
41
|
+
}),
|
|
42
|
+
expect.objectContaining({
|
|
43
|
+
knowledgeBaseId: 'kb-disabled',
|
|
44
|
+
access: 'denied',
|
|
45
|
+
reason: expect.stringContaining('disabled'),
|
|
46
|
+
}),
|
|
47
|
+
]),
|
|
48
|
+
);
|
|
49
|
+
expect(matrix.find((row) => row.knowledgeBaseId === 'kb-explicit')?.userGate).toContain('allowed KB role');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('reads current NocoBase knowledgeBaseIds settings and removes duplicate assignments', () => {
|
|
53
|
+
const matrix = buildKnowledgeAccessMatrix(
|
|
54
|
+
[
|
|
55
|
+
{
|
|
56
|
+
username: 'current-config-agent',
|
|
57
|
+
knowledgeBase: { knowledgeBaseIds: ['kb-current', 'kb-current'] },
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
[{ id: 'kb-current', name: 'Current configuration', enabled: true, agentAccess: 'inherit' }],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
expect(matrix).toEqual([
|
|
64
|
+
expect.objectContaining({
|
|
65
|
+
employeeUsername: 'current-config-agent',
|
|
66
|
+
knowledgeBaseId: 'kb-current',
|
|
67
|
+
assigned: true,
|
|
68
|
+
access: 'allowed',
|
|
69
|
+
}),
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('returns a citation-only view of external RAG spans and never surfaces raw metadata', () => {
|
|
74
|
+
const trace = summarizeRetrievalSpan({
|
|
75
|
+
id: 42,
|
|
76
|
+
employeeUsername: 'researcher',
|
|
77
|
+
status: 'success',
|
|
78
|
+
input: { query: 'deployment' },
|
|
79
|
+
output: JSON.stringify({
|
|
80
|
+
query: 'deployment',
|
|
81
|
+
results: [
|
|
82
|
+
{
|
|
83
|
+
knowledgeBaseId: 'kb-public',
|
|
84
|
+
knowledgeBaseName: 'Public docs',
|
|
85
|
+
content: 'Use the deployment checklist before release.',
|
|
86
|
+
score: 0.98,
|
|
87
|
+
source: { id: 'document-1', filename: 'deploy.md', url: 'https://example.test/deploy.md' },
|
|
88
|
+
metadata: { apiKey: 'must-not-appear' },
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
expect(trace).toMatchObject({
|
|
95
|
+
id: 42,
|
|
96
|
+
decision: 'allowed',
|
|
97
|
+
query: 'deployment',
|
|
98
|
+
citations: [
|
|
99
|
+
{
|
|
100
|
+
knowledgeBaseId: 'kb-public',
|
|
101
|
+
filename: 'deploy.md',
|
|
102
|
+
score: 0.98,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
});
|
|
106
|
+
expect(JSON.stringify(trace)).not.toContain('must-not-appear');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('records a denial reason when the retrieval tool fails', () => {
|
|
110
|
+
const trace = summarizeRetrievalSpan({
|
|
111
|
+
status: 'error',
|
|
112
|
+
input: { query: 'private notes' },
|
|
113
|
+
error: 'Knowledge base is not assigned to this AI Employee.',
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
expect(trace).toMatchObject({
|
|
117
|
+
decision: 'denied',
|
|
118
|
+
query: 'private notes',
|
|
119
|
+
reason: 'Knowledge base is not assigned to this AI Employee.',
|
|
120
|
+
citations: [],
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|