refactor: 项目更名 WeKnora → Academy
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名) - 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块) - docreader proto 描述符采用等长替换,保持序列化字节布局有效 - Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像 - 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
This commit is contained in:
1 parent
9097ee699d
commit
9058149576
3136 files changed
+18018
-18004
No files matched your search
@@ -9,7 +9,7 @@ codec lives in this one package:
|
||||
| `registry.go` | `Registry` facade — the only type request lifecycles use |
|
||||
| `handle_table.go` | `handleTable[M]`, the generic bidirectional primitive behind every handle space |
|
||||
| `sources.go` | source handles (`chunk://N`/`doc://N`/`kb://N`/`url://N`) and the tool-argument codec |
|
||||
| `source_text.go` | handle syntax, `weknora://` durable URIs, and free-text / streaming handle rewriting |
|
||||
| `source_text.go` | handle syntax, `academy://` durable URIs, and free-text / streaming handle rewriting |
|
||||
| `citations.go` | protocol prompts, `<ref/>` → `<kb/>`/`<web/>` expansion, citation stream expander |
|
||||
| `model_output.go` | compact source-centric renderings of tool results |
|
||||
| `resources.go` | durable-resource handles (`res://NNNN`) |
|
||||
@@ -27,8 +27,8 @@ codec lives in this one package:
|
||||
- Request-local model handles: `chunk://N`, `doc://N`, `kb://N`, `url://N`,
|
||||
`msN`, `mtN`, and `res://NNNN`. The legacy bare `cN`/`dN`/`bN`/`wN` form is
|
||||
still accepted, but only as the whole value of a declared ID field.
|
||||
- Durable text forms of source handles: `weknora://kb/<id>`,
|
||||
`weknora://doc/<id>`, `weknora://chunk/<id>`; a web page becomes its URL.
|
||||
- Durable text forms of source handles: `academy://kb/<id>`,
|
||||
`academy://doc/<id>`, `academy://chunk/<id>`; a web page becomes its URL.
|
||||
- Tool-private request handles: `iN` for Wiki issues.
|
||||
- Ingest-call handles: `cNNN` and `ref-N`, allocated with `HandleTable`.
|
||||
- Temporary handles are decoded before tool execution, persistence, or UI
|
||||
@@ -102,13 +102,13 @@ rewrites handles in every string, not just declared fields:
|
||||
|
||||
- Tool arguments (built-in and MCP): declared ID fields receive bare durable
|
||||
IDs, SQL fields receive bare IDs, and every other string receives the durable
|
||||
text form (`weknora://kb/<id>`, `weknora://doc/<id>`, `weknora://chunk/<id>`,
|
||||
text form (`academy://kb/<id>`, `academy://doc/<id>`, `academy://chunk/<id>`,
|
||||
or the page URL). An unknown handle anywhere in the arguments fails closed.
|
||||
- Model output (complete and streaming, content and reasoning): `<ref/>`
|
||||
citations expand as before; bare `kb://N`/`doc://N` become `weknora://` URIs,
|
||||
citations expand as before; bare `kb://N`/`doc://N` become `academy://` URIs,
|
||||
`url://N` becomes the URL, and `chunk://N` becomes a `<kb/>` citation when it
|
||||
is current evidence, otherwise its document URI. Unknown handles are dropped.
|
||||
- Input: `weknora://` URIs in any message, reasoning or replayed tool call are
|
||||
- Input: `academy://` URIs in any message, reasoning or replayed tool call are
|
||||
registered as navigation-only handles and shown to the model as handles, so
|
||||
a saved instruction round-trips across requests and agents.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// ImageSourcesNote binds images to handles already present in the final model
|
||||
|
||||
@@ -3,7 +3,7 @@ package modelcontext
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"academy/internal/models/chat"
|
||||
)
|
||||
|
||||
var uuidShapeRE = regexp.MustCompile(
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// normalizeMCPCallArguments tolerates one extra JSON encoding of the bridge's
|
||||
|
||||
@@ -5,14 +5,14 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMCPAnswerCannotBorrowDirectoryOrHistoricalKnowledgeCitations(t *testing.T) {
|
||||
r := NewRegistry(true)
|
||||
r.RegisterContextChunk(ChunkReference{ChunkID: "faq-1", DocumentTitle: "什么是 WeKnora?"})
|
||||
r.RegisterContextChunk(ChunkReference{ChunkID: "faq-1", DocumentTitle: "什么是 Academy?"})
|
||||
r.RegisterContextChunk(ChunkReference{ChunkID: "faq-2", DocumentTitle: "如何创建知识库?"})
|
||||
history := []chat.Message{{Role: "assistant", Content: `物业工作 <kb doc="9月13日周报.docx" chunk_id="weekly-report" />`}}
|
||||
r.EncodeMessages(history)
|
||||
@@ -44,7 +44,7 @@ func TestMCPAnswerCannotBorrowDirectoryOrHistoricalKnowledgeCitations(t *testing
|
||||
r.ModelToolResultForTool("knowledge_search", &types.ToolResult{Success: true, Data: map[string]interface{}{
|
||||
"display_type": "search_results",
|
||||
"results": []map[string]interface{}{{
|
||||
"chunk_id": "faq-1", "knowledge_title": "什么是 WeKnora?", "content": "知识库管理系统",
|
||||
"chunk_id": "faq-1", "knowledge_title": "什么是 Academy?", "content": "知识库管理系统",
|
||||
}},
|
||||
}})
|
||||
r.RegisterContextChunk(ChunkReference{ChunkID: "faq-1"})
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Its boundaries are deliberate:
|
||||
// - UUIDs, wiki slugs, URLs, and resource:// handles are durable identities.
|
||||
// - kb://N, doc://N, chunk://N, url://N, iN, res://NNNN and ref-N values are
|
||||
// temporary model handles; weknora:// URIs are their durable text form.
|
||||
// temporary model handles; academy:// URIs are their durable text form.
|
||||
// - temporary handles are never persisted or accepted outside their registry.
|
||||
// - every model response is decoded before tools, storage, or UI consume it.
|
||||
package modelcontext
|
||||
@@ -16,9 +16,9 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/api"
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
func TestRegistryOwnsEncodingOrderForSummarySlugs(t *testing.T) {
|
||||
@@ -272,8 +272,8 @@ func TestRegistryDoesNotApplyBuiltInFieldPoliciesToDynamicTools(t *testing.T) {
|
||||
// Dynamic tools own no ID fields: every handle becomes its durable text
|
||||
// form, and tool-private iN handles stay opaque.
|
||||
require.JSONEq(t,
|
||||
`{"issue_id":"i1","knowledge_id":"weknora://doc/doc-real","url":"https://example.com",`+
|
||||
`"sql":"SELECT 'weknora://doc/doc-real'"}`,
|
||||
`{"issue_id":"i1","knowledge_id":"academy://doc/doc-real","url":"https://example.com",`+
|
||||
`"sql":"SELECT 'academy://doc/doc-real'"}`,
|
||||
calls[0].Function.Arguments)
|
||||
require.Equal(t, ArgumentResolutionResolved, calls[0].ArgumentResolution)
|
||||
require.Empty(t, calls[0].UnresolvedHandles)
|
||||
@@ -368,7 +368,7 @@ func TestRegistryDecodesCanonicalArgumentsForEveryBuiltInReferenceTool(t *testin
|
||||
{
|
||||
"knowledge search KB", "knowledge_search",
|
||||
`{"queries":["doc://1"],"knowledge_base_ids":["kb://1"]}`,
|
||||
`{"queries":["weknora://doc/doc-real"],"knowledge_base_ids":["kb-real"]}`,
|
||||
`{"queries":["academy://doc/doc-real"],"knowledge_base_ids":["kb-real"]}`,
|
||||
},
|
||||
{"list document", "list_knowledge_chunks", `{"knowledge_id":"doc://1"}`, `{"knowledge_id":"doc-real"}`},
|
||||
{"list chunk", "list_knowledge_chunks", `{"chunk_id":"chunk://1"}`, `{"chunk_id":"chunk-real"}`},
|
||||
@@ -385,7 +385,7 @@ func TestRegistryDecodesCanonicalArgumentsForEveryBuiltInReferenceTool(t *testin
|
||||
{
|
||||
"data analysis SQL", "data_analysis",
|
||||
`{"knowledge_id":"doc://1","sql":"SELECT COUNT(*) FROM dataset WHERE label = 'doc://1'"}`,
|
||||
`{"knowledge_id":"doc-real","sql":"SELECT COUNT(*) FROM dataset WHERE label = 'weknora://doc/doc-real'"}`,
|
||||
`{"knowledge_id":"doc-real","sql":"SELECT COUNT(*) FROM dataset WHERE label = 'academy://doc/doc-real'"}`,
|
||||
},
|
||||
{"data schema", "data_schema", `{"knowledge_id":"doc://1"}`, `{"knowledge_id":"doc-real"}`},
|
||||
{
|
||||
@@ -564,7 +564,7 @@ func TestRegistryDecodesReadDocumentIDAgainstBothHandleTables(t *testing.T) {
|
||||
{
|
||||
"read document query decodes handles to durable text", "read_document",
|
||||
`{"id":"doc://1","query":"doc://1 chunk://1"}`,
|
||||
`{"id":"doc-real","query":"weknora://doc/doc-real weknora://chunk/chunk-real"}`,
|
||||
`{"id":"doc-real","query":"academy://doc/doc-real academy://chunk/chunk-real"}`,
|
||||
},
|
||||
{
|
||||
"search knowledge KB", "search_knowledge",
|
||||
@@ -591,7 +591,7 @@ func TestRegistryDecodesReadDocumentIDAgainstBothHandleTables(t *testing.T) {
|
||||
// field: the handle becomes durable text instead of a bare ID.
|
||||
calls := []types.LLMToolCall{{Function: types.FunctionCall{Name: "thinking", Arguments: `{"id":"doc://1"}`}}}
|
||||
registry.DecodeToolCalls(calls)
|
||||
require.JSONEq(t, `{"id":"weknora://doc/doc-real"}`, calls[0].Function.Arguments)
|
||||
require.JSONEq(t, `{"id":"academy://doc/doc-real"}`, calls[0].Function.Arguments)
|
||||
|
||||
unknown := []types.LLMToolCall{{Function: types.FunctionCall{Name: "read_document", Arguments: `{"id":"doc://9"}`}}}
|
||||
registry.DecodeToolCalls(unknown)
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/api"
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// storedRefRE also recognizes legacy physical references. New writes persist
|
||||
|
||||
@@ -3,8 +3,8 @@ package modelcontext
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ func TestRegistryAliasesWikiSummarySlug(t *testing.T) {
|
||||
func TestRegistryLeavesEntitySlugUntouched(t *testing.T) {
|
||||
r := newResourceRegistry()
|
||||
// Entity slugs are low-entropy and semantically meaningful; not aliased.
|
||||
entity := "[[entity/weknora-error-log|WeKnora 试错记录]]"
|
||||
entity := "[[entity/academy-error-log|Academy 试错记录]]"
|
||||
require.Equal(t, entity, r.EncodeText(entity))
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ package modelcontext
|
||||
// arguments alike — instead of only in a fixed list of ID fields.
|
||||
//
|
||||
// Durable text forms are what a decoded handle becomes outside an ID field:
|
||||
// a web page becomes its URL, and workspace objects become weknora:// URIs
|
||||
// a web page becomes its URL, and workspace objects become academy:// URIs
|
||||
// that a later request encodes back into its own handles.
|
||||
import (
|
||||
"regexp"
|
||||
@@ -20,7 +20,7 @@ const (
|
||||
kbHandlePrefix = "kb://"
|
||||
webHandlePrefix = "url://"
|
||||
|
||||
durableURIScheme = "weknora://"
|
||||
durableURIScheme = "academy://"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -46,7 +46,7 @@ var legacyHandlePrefixes = map[byte]string{
|
||||
'c': chunkHandlePrefix, 'd': docHandlePrefix, 'b': kbHandlePrefix, 'w': webHandlePrefix,
|
||||
}
|
||||
|
||||
var durableURIRE = regexp.MustCompile(`(?i)weknora://(kb|doc|chunk)/([0-9A-Za-z][0-9A-Za-z_\-]*)`)
|
||||
var durableURIRE = regexp.MustCompile(`(?i)academy://(kb|doc|chunk)/([0-9A-Za-z][0-9A-Za-z_\-]*)`)
|
||||
|
||||
// parseSourceHandleToken returns the canonical handle for one scheme-shaped
|
||||
// token, or "" when the token body is not a positive integer.
|
||||
@@ -83,7 +83,7 @@ func durableURI(kind, id string) string {
|
||||
}
|
||||
|
||||
// parseDurableURI returns the kind and ID when value is exactly one
|
||||
// weknora:// URI.
|
||||
// academy:// URI.
|
||||
func parseDurableURI(value string) (kind, id string, ok bool) {
|
||||
value = strings.TrimSpace(value)
|
||||
match := durableURIRE.FindStringSubmatch(value)
|
||||
@@ -118,7 +118,7 @@ func (r *sourceRegistry) resolveSourceHandle(handle string) (prefix, durable str
|
||||
}
|
||||
|
||||
// durableTextForHandle is the form a handle takes in stored or forwarded
|
||||
// text: a URL for web pages, a weknora:// URI for workspace objects.
|
||||
// text: a URL for web pages, a academy:// URI for workspace objects.
|
||||
func (r *sourceRegistry) durableTextForHandle(handle string) string {
|
||||
prefix, durable, _, ok := r.resolveSourceHandle(handle)
|
||||
if !ok {
|
||||
@@ -189,7 +189,7 @@ func (r *sourceRegistry) UnresolvedTextHandles(text string) []string {
|
||||
return unresolved
|
||||
}
|
||||
|
||||
// EncodeDurableURIs replaces weknora:// URIs with this request's handles.
|
||||
// EncodeDurableURIs replaces academy:// URIs with this request's handles.
|
||||
// Registration only makes the object addressable; tools still authorize
|
||||
// every durable ID they receive.
|
||||
func (r *sourceRegistry) EncodeDurableURIs(text string) string {
|
||||
@@ -218,7 +218,7 @@ func (r *sourceRegistry) registerDurable(kind, id string) string {
|
||||
}
|
||||
|
||||
// ExpandHandleText renders handles in user-visible text. Workspace objects
|
||||
// become weknora:// links the client resolves, web pages become their URL,
|
||||
// become academy:// links the client resolves, web pages become their URL,
|
||||
// and a chunk becomes a citation when it is current evidence, or its
|
||||
// document otherwise. Unknown handles are dropped, like unknown <ref/> tags.
|
||||
func (r *sourceRegistry) ExpandHandleText(text string) string {
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -19,8 +19,8 @@ func TestOutputTextExpandsHandlesAnywhereWithoutTouchingProse(t *testing.T) {
|
||||
got := registry.DecodeOutputText(
|
||||
"维生素 B1 与 W6 型号; 入库 kb://1, 文档 doc://1, 来源 [榜单](url://1), 片段 chunk://1, 未知 kb://9.")
|
||||
require.Equal(t,
|
||||
"维生素 B1 与 W6 型号; 入库 weknora://kb/kb-real, 文档 weknora://doc/doc-real, "+
|
||||
"来源 [榜单](https://example.com/hot), 片段 weknora://doc/doc-real, 未知 .",
|
||||
"维生素 B1 与 W6 型号; 入库 academy://kb/kb-real, 文档 academy://doc/doc-real, "+
|
||||
"来源 [榜单](https://example.com/hot), 片段 academy://doc/doc-real, 未知 .",
|
||||
got)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestStreamDecoderExpandsHandlesSplitAtAnyByte(t *testing.T) {
|
||||
registry.RegisterKnowledgeBase("kb-real")
|
||||
registry.RegisterWeb("https://example.com/a", "")
|
||||
text := "undo: kb://1 then url://1; doc text ends with k"
|
||||
want := "undo: weknora://kb/kb-real then https://example.com/a; doc text ends with k"
|
||||
want := "undo: academy://kb/kb-real then https://example.com/a; doc text ends with k"
|
||||
for split := 1; split < len(text); split++ {
|
||||
decoder := registry.StreamDecoder()
|
||||
got := decoder.Feed(text[:split]) + decoder.Feed(text[split:]) + decoder.Flush()
|
||||
@@ -102,7 +102,7 @@ func TestSavedInstructionRoundTripsAcrossRequests(t *testing.T) {
|
||||
instruction := stored.Params.Instruction
|
||||
require.Equal(t,
|
||||
"抓取 https://dataxapi.com/zh/tools/hot-search/zhihu.md 并用 knowledge.create_manual 写入 "+
|
||||
"weknora://kb/kb-archive,参数 knowledge_base_id: weknora://kb/kb-archive",
|
||||
"academy://kb/kb-archive,参数 knowledge_base_id: academy://kb/kb-archive",
|
||||
instruction)
|
||||
|
||||
// The echo of the saved instruction reads back in the writer's own handles,
|
||||
@@ -135,12 +135,12 @@ func TestDelegatedTaskCarriesDurableReferencesToTheChild(t *testing.T) {
|
||||
Name: "spawn_agent", Arguments: `{"task":"Summarize doc://1 from kb://1"}`,
|
||||
}}}
|
||||
parent.DecodeToolCalls(calls)
|
||||
require.JSONEq(t, `{"task":"Summarize weknora://doc/doc-a from weknora://kb/kb-a"}`, calls[0].Function.Arguments)
|
||||
require.JSONEq(t, `{"task":"Summarize academy://doc/doc-a from academy://kb/kb-a"}`, calls[0].Function.Arguments)
|
||||
|
||||
child := NewRegistry(true)
|
||||
child.RegisterKnowledgeBase("kb-child-bound")
|
||||
encoded := child.EncodeMessages([]chat.Message{{
|
||||
Role: "user", Content: "Summarize weknora://doc/doc-a from weknora://kb/kb-a",
|
||||
Role: "user", Content: "Summarize academy://doc/doc-a from academy://kb/kb-a",
|
||||
}})
|
||||
require.Equal(t, "Summarize doc://1 from kb://2", encoded[0].Content)
|
||||
}
|
||||
@@ -158,7 +158,7 @@ func TestUnknownHandleInFreeTextFailsClosed(t *testing.T) {
|
||||
func TestDurableURIInIDFieldDecodesToBareID(t *testing.T) {
|
||||
registry := NewRegistry(true)
|
||||
calls := []types.LLMToolCall{{Function: types.FunctionCall{
|
||||
Name: "list_documents", Arguments: `{"knowledge_base_id":"weknora://kb/kb-real"}`,
|
||||
Name: "list_documents", Arguments: `{"knowledge_base_id":"academy://kb/kb-real"}`,
|
||||
}}}
|
||||
registry.DecodeToolCalls(calls)
|
||||
require.JSONEq(t, `{"knowledge_base_id":"kb-real"}`, calls[0].Function.Arguments)
|
||||
@@ -167,11 +167,11 @@ func TestDurableURIInIDFieldDecodesToBareID(t *testing.T) {
|
||||
func TestHistoryAnswerWithDurableURIsReplaysAsHandles(t *testing.T) {
|
||||
registry := NewRegistry(true)
|
||||
encoded := registry.EncodeMessages([]chat.Message{
|
||||
{Role: "assistant", Content: "已写入 weknora://kb/kb-real", ReasoningContent: "target weknora://kb/kb-real"},
|
||||
{Role: "assistant", Content: "已写入 academy://kb/kb-real", ReasoningContent: "target academy://kb/kb-real"},
|
||||
})
|
||||
require.Equal(t, "已写入 kb://1", encoded[0].Content)
|
||||
require.Equal(t, "target kb://1", encoded[0].ReasoningContent)
|
||||
require.Equal(t, "已写入 weknora://kb/kb-real", registry.DecodeOutputText(encoded[0].Content))
|
||||
require.Equal(t, "已写入 academy://kb/kb-real", registry.DecodeOutputText(encoded[0].Content))
|
||||
}
|
||||
|
||||
func mustJSON(t *testing.T, value string) string {
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
type ChunkReference struct {
|
||||
@@ -217,7 +217,7 @@ type toolArgumentPolicy func(toolName, key string) bool
|
||||
// explicitly owned by the named tool receive the bare durable ID, so dynamic
|
||||
// tools with coincidentally named fields do not inherit built-in source
|
||||
// semantics; bareText fields (SQL) receive bare IDs inside the expression;
|
||||
// all other text receives durable text forms (URLs and weknora:// URIs).
|
||||
// all other text receives durable text forms (URLs and academy:// URIs).
|
||||
func (r *sourceRegistry) DecodeToolCallsWithPolicy(
|
||||
toolCalls []types.LLMToolCall,
|
||||
policy toolArgumentPolicy,
|
||||
@@ -310,7 +310,7 @@ func (r *sourceRegistry) EncodeMessagesWithPolicies(
|
||||
for i := range out {
|
||||
processToolResult := out[i].Role == "tool" && (resultPolicy == nil || resultPolicy(out[i].Name))
|
||||
// Stored text (instructions, prompts, earlier answers) carries
|
||||
// workspace objects as weknora:// URIs in every role.
|
||||
// workspace objects as academy:// URIs in every role.
|
||||
reasoningBefore := out[i].ReasoningContent
|
||||
if out[i].Role == "assistant" || processToolResult {
|
||||
out[i].Content = r.CompactPublicCitations(out[i].Content, false)
|
||||
@@ -539,13 +539,13 @@ func (r *sourceRegistry) durableForHandle(handle string) string {
|
||||
}
|
||||
|
||||
// CompactKnownText is intentionally limited to identifiers already registered
|
||||
// from structured runtime/tool data, plus explicit weknora:// URIs. It is used
|
||||
// from structured runtime/tool data, plus explicit academy:// URIs. It is used
|
||||
// for metadata envelopes, not arbitrary retrieved prose.
|
||||
func (r *sourceRegistry) CompactKnownText(text string) string {
|
||||
if r == nil || text == "" {
|
||||
return text
|
||||
}
|
||||
// URIs first: their embedded IDs must become one handle, not "weknora://kb/kb://1".
|
||||
// URIs first: their embedded IDs must become one handle, not "academy://kb/kb://1".
|
||||
text = r.EncodeDurableURIs(text)
|
||||
// The snapshot spans all four source tables and is sorted longest-value
|
||||
// first GLOBALLY: a web URL may contain a registered document UUID as a
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestDecodeToolCallsGivesFreeTextDurableFormsAndIDFieldsBareIDs(t *testing.T
|
||||
registry.RegisterKnowledgeBase("kb-uuid-1")
|
||||
|
||||
// Declared ID-bearing keys resolve to real IDs; handles in free text become
|
||||
// weknora:// URIs a later request can encode again; legacy-shaped prose
|
||||
// academy:// URIs a later request can encode again; legacy-shaped prose
|
||||
// such as "b1" is never rewritten.
|
||||
calls := []types.LLMToolCall{{
|
||||
Function: types.FunctionCall{
|
||||
@@ -104,7 +104,7 @@ func TestDecodeToolCallsGivesFreeTextDurableFormsAndIDFieldsBareIDs(t *testing.T
|
||||
registry.DecodeToolCalls(calls)
|
||||
|
||||
require.JSONEq(t,
|
||||
`{"query":"b1","content":"see weknora://kb/kb-uuid-1 for details","knowledge_base_ids":["kb-uuid-1"]}`,
|
||||
`{"query":"b1","content":"see academy://kb/kb-uuid-1 for details","knowledge_base_ids":["kb-uuid-1"]}`,
|
||||
calls[0].Function.Arguments,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"academy/internal/models/chat"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -163,8 +163,8 @@ var toolHandlePolicies = map[string]toolHandlePolicy{
|
||||
},
|
||||
// The bundled documentation is static text with public URLs; it carries no
|
||||
// workspace identifiers.
|
||||
"search_weknora_docs": {},
|
||||
"read_weknora_doc": {},
|
||||
"search_academy_docs": {},
|
||||
"read_academy_doc": {},
|
||||
// The operation catalog names parameters and result fields with the
|
||||
// canonical keys below, so handles decode inside params and returned IDs
|
||||
// come back as handles. Catalog metadata itself carries no identifiers.
|
||||
@@ -259,7 +259,7 @@ func sourceArgumentAllowed(toolName, key string) bool {
|
||||
}
|
||||
|
||||
// sourceBareTextAllowed reports structured-text arguments (SQL) whose handles
|
||||
// must decode to bare durable IDs rather than weknora:// URIs.
|
||||
// must decode to bare durable IDs rather than academy:// URIs.
|
||||
func sourceBareTextAllowed(toolName, key string) bool {
|
||||
policy, ok := toolHandlePolicies[toolName]
|
||||
if !ok {
|
||||
|
||||
Reference in new issue
Block a user