@things-factory/ai-client-base 10.1.277 → 10.1.279
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-server/service/agent/ai-client-for.js +2 -0
- package/dist-server/service/agent/ai-model-price.d.ts +22 -0
- package/dist-server/service/agent/ai-model-price.js +81 -0
- package/dist-server/service/agent/ai-usage-summary.d.ts +8 -1
- package/dist-server/service/agent/ai-usage-summary.js +17 -4
- package/dist-server/service/agent/ai-usage.d.ts +2 -0
- package/dist-server/service/agent/ai-usage.js +12 -2
- package/dist-server/service/agent/index.d.ts +2 -0
- package/dist-server/service/agent/index.js +4 -1
- package/dist-server/service/agent/model-price-boot.d.ts +1 -0
- package/dist-server/service/agent/model-price-boot.js +14 -0
- package/dist-server/service/agent/model-price.d.ts +77 -0
- package/dist-server/service/agent/model-price.js +214 -0
- package/dist-server/service/index.d.ts +3 -1
- package/dist-server/service/index.js +3 -1
- package/dist-server/service/providers/anthropic.js +2 -5
- package/dist-server/service/providers/gemini.js +2 -6
- package/dist-server/service/providers/openai.js +2 -5
- package/dist-server/service/providers/usage.d.ts +18 -0
- package/dist-server/service/providers/usage.js +50 -0
- package/dist-server/service/types.d.ts +6 -0
- package/package.json +20 -6
- package/translations/en.json +5 -1
- package/translations/es.json +5 -1
- package/translations/ja.json +5 -1
- package/translations/ko.json +5 -1
- package/translations/ms.json +5 -1
- package/translations/zh.json +5 -1
- package/dist-server/index.js.map +0 -1
- package/dist-server/service/agent/agent-directory.js.map +0 -1
- package/dist-server/service/agent/agent-settings-save.js.map +0 -1
- package/dist-server/service/agent/agent-spec.js.map +0 -1
- package/dist-server/service/agent/ai-client-for.js.map +0 -1
- package/dist-server/service/agent/ai-usage-summary.js.map +0 -1
- package/dist-server/service/agent/ai-usage.js.map +0 -1
- package/dist-server/service/agent/index.js.map +0 -1
- package/dist-server/service/agent/provider-models.js.map +0 -1
- package/dist-server/service/agentic-loop/agentic-loop.js.map +0 -1
- package/dist-server/service/agentic-loop/index.js.map +0 -1
- package/dist-server/service/analysis-contract.js.map +0 -1
- package/dist-server/service/assistant/abort-notice.js.map +0 -1
- package/dist-server/service/assistant/assistant-chat.js.map +0 -1
- package/dist-server/service/assistant/index.js.map +0 -1
- package/dist-server/service/assistant/open-subject.js.map +0 -1
- package/dist-server/service/assistant/registry-assistant.js.map +0 -1
- package/dist-server/service/assistant/registry-gate.js.map +0 -1
- package/dist-server/service/assistant/summarize.js.map +0 -1
- package/dist-server/service/assistant/tool-budget.js.map +0 -1
- package/dist-server/service/assistant/tool-scope.js.map +0 -1
- package/dist-server/service/capability.js.map +0 -1
- package/dist-server/service/decision/config.js.map +0 -1
- package/dist-server/service/decision/decision.js.map +0 -1
- package/dist-server/service/decision/index.js.map +0 -1
- package/dist-server/service/decision/jev.js.map +0 -1
- package/dist-server/service/factory.js.map +0 -1
- package/dist-server/service/index.js.map +0 -1
- package/dist-server/service/providers/anthropic.js.map +0 -1
- package/dist-server/service/providers/gemini.js.map +0 -1
- package/dist-server/service/providers/index.js.map +0 -1
- package/dist-server/service/providers/openai.js.map +0 -1
- package/dist-server/service/providers/request-options.js.map +0 -1
- package/dist-server/service/testing/tool-call-context.js.map +0 -1
- package/dist-server/service/tool-registry/call-recorder.js.map +0 -1
- package/dist-server/service/tool-registry/index.js.map +0 -1
- package/dist-server/service/tool-registry/registry.js.map +0 -1
- package/dist-server/service/tool-registry/translate.js.map +0 -1
- package/dist-server/service/tool-registry/types.js.map +0 -1
- package/dist-server/service/types.js.map +0 -1
- package/dist-server/service/utils/grounding.js.map +0 -1
- package/dist-server/service/utils/index.js.map +0 -1
- package/dist-server/service/utils/parse-json.js.map +0 -1
- package/dist-server/service/utils/transient.js.map +0 -1
- package/dist-server/tsconfig.tsbuildinfo +0 -1
- package/docs/grounded-analysis-contract.md +0 -54
- package/experiments/entity360/README.md +0 -224
- package/experiments/entity360/apps.cjs +0 -103
- package/experiments/entity360/apps.test.cjs +0 -24
- package/experiments/entity360/baseline-apps-results.json +0 -3357
- package/experiments/entity360/baseline-expanded-results.json +0 -5952
- package/experiments/entity360/baseline-results.json +0 -1507
- package/experiments/entity360/expanded.cjs +0 -65
- package/experiments/entity360/fixtures.json +0 -100
- package/experiments/entity360/index.html +0 -44
- package/experiments/entity360/jev-apps-results.json +0 -3440
- package/experiments/entity360/jev-expanded-results.json +0 -6095
- package/experiments/entity360/jev-results.json +0 -1542
- package/experiments/entity360/run.cjs +0 -100
- package/server/index.ts +0 -19
- package/server/service/agent/agent-directory.test.ts +0 -206
- package/server/service/agent/agent-directory.ts +0 -198
- package/server/service/agent/agent-settings-save.test.ts +0 -151
- package/server/service/agent/agent-settings-save.ts +0 -205
- package/server/service/agent/agent-spec.ts +0 -103
- package/server/service/agent/ai-client-for.test.ts +0 -170
- package/server/service/agent/ai-client-for.ts +0 -215
- package/server/service/agent/ai-usage-summary.test.ts +0 -65
- package/server/service/agent/ai-usage-summary.ts +0 -146
- package/server/service/agent/ai-usage.ts +0 -97
- package/server/service/agent/index.ts +0 -7
- package/server/service/agent/one-door.test.ts +0 -57
- package/server/service/agent/provider-models.ts +0 -43
- package/server/service/agentic-loop/agentic-loop.test.ts +0 -1118
- package/server/service/agentic-loop/agentic-loop.ts +0 -745
- package/server/service/agentic-loop/index.ts +0 -1
- package/server/service/agentic-loop/proposal-key.test.ts +0 -83
- package/server/service/analysis-contract.test.ts +0 -20
- package/server/service/analysis-contract.ts +0 -77
- package/server/service/assistant/abort-notice.ts +0 -67
- package/server/service/assistant/assistant-chat.test.ts +0 -240
- package/server/service/assistant/assistant-chat.ts +0 -104
- package/server/service/assistant/index.ts +0 -13
- package/server/service/assistant/open-subject.test.ts +0 -91
- package/server/service/assistant/open-subject.ts +0 -140
- package/server/service/assistant/registry-assistant.test.ts +0 -627
- package/server/service/assistant/registry-assistant.ts +0 -240
- package/server/service/assistant/registry-gate.ts +0 -76
- package/server/service/assistant/summarize.ts +0 -47
- package/server/service/assistant/tool-budget.test.ts +0 -246
- package/server/service/assistant/tool-budget.ts +0 -186
- package/server/service/assistant/tool-scope.test.ts +0 -123
- package/server/service/assistant/tool-scope.ts +0 -103
- package/server/service/capability.test.ts +0 -40
- package/server/service/capability.ts +0 -49
- package/server/service/decision/config.test.ts +0 -55
- package/server/service/decision/config.ts +0 -49
- package/server/service/decision/decision.test.ts +0 -94
- package/server/service/decision/decision.ts +0 -112
- package/server/service/decision/index.ts +0 -3
- package/server/service/decision/jev.ts +0 -40
- package/server/service/factory.ts +0 -28
- package/server/service/index.ts +0 -17
- package/server/service/providers/anthropic.ts +0 -274
- package/server/service/providers/gemini.ts +0 -396
- package/server/service/providers/index.ts +0 -8
- package/server/service/providers/json-answer.test.ts +0 -53
- package/server/service/providers/openai-models.test.ts +0 -30
- package/server/service/providers/openai.ts +0 -326
- package/server/service/providers/request-options.ts +0 -12
- package/server/service/providers/request-signal.test.ts +0 -77
- package/server/service/providers/transcribe.test.ts +0 -18
- package/server/service/testing/tool-call-context.ts +0 -38
- package/server/service/tool-registry/call-recorder.ts +0 -116
- package/server/service/tool-registry/index.ts +0 -50
- package/server/service/tool-registry/registry.test.ts +0 -319
- package/server/service/tool-registry/registry.ts +0 -248
- package/server/service/tool-registry/translate.ts +0 -12
- package/server/service/tool-registry/types.ts +0 -305
- package/server/service/types.ts +0 -221
- package/server/service/utils/grounding.test.ts +0 -119
- package/server/service/utils/grounding.ts +0 -131
- package/server/service/utils/index.ts +0 -3
- package/server/service/utils/parse-json.ts +0 -116
- package/server/service/utils/transient.test.ts +0 -92
- package/server/service/utils/transient.ts +0 -92
- package/tsconfig.json +0 -9
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool Registry — board-ai 의 LLM tool 노출 plugin point.
|
|
3
|
-
*
|
|
4
|
-
* 동기:
|
|
5
|
-
* 기존엔 board-ai 가 자기 도메인 (board edit) tool 들만 hardcoded 정의했고, styling
|
|
6
|
-
* 영역만 STYLING_TOOLS registry 로 분리되어 있었다. 외부 도메인 패키지 (board-import,
|
|
7
|
-
* fmsim 등) 가 자기 tool 을 LLM 에 노출하려면 board-ai 자체를 fork/수정해야 했다.
|
|
8
|
-
*
|
|
9
|
-
* 본 registry 는 외부 패키지가 server bootstrap 시 자기 tool category 를 등록하면
|
|
10
|
-
* assistant.ts 의 buildBoardEditTools / dispatch / isWriteTool 등이 자동으로 통합
|
|
11
|
-
* 하도록 한다. styling-tools 의 single-source-of-truth 패턴을 일반화한 형태.
|
|
12
|
-
*
|
|
13
|
-
* 설계 원칙:
|
|
14
|
-
* - **카테고리별 builder 시그니처 다양성을 통합**: read 는 (args, ctx) → any,
|
|
15
|
-
* write 는 (args, components) → SceneEditOp[], action 은 (args) → SceneActionOp.
|
|
16
|
-
* 하나의 ToolSpec 에 모든 시그니처를 union 으로 담지 않고, 카테고리에 맞는
|
|
17
|
-
* builder 만 채우면 되도록 카테고리별 sub-interface 분리.
|
|
18
|
-
* - **kind 필드로 자가 분류**: registry 가 isReadTool / isWriteTool 자동 도출.
|
|
19
|
-
* hardcoded set 동기화 누락 위험 제거.
|
|
20
|
-
* - **점진 마이그레이션**: 기존 STYLING_TOOLS 가 본 registry 의 첫 사용자.
|
|
21
|
-
* 점진적으로 다른 hardcoded tool 들 (addComponent / alignComponents 등) 도
|
|
22
|
-
* 같은 registry 로 흡수 가능. 한 단계씩 byte-단위 동등성 단위 테스트 보장.
|
|
23
|
-
*/
|
|
24
|
-
// 본 registry 는 LLM tool 노출 plugin point 에 한정되므로 도메인 type (SceneEditOp,
|
|
25
|
-
// SceneActionOp 등) 은 알지 않는다. builder return 은 unknown 으로 두고, 카테고리
|
|
26
|
-
// dispatcher (board-ai 의 toolCallToSceneEditOp / toolCallToSceneActionOp 등) 가 자기
|
|
27
|
-
// 도메인 type 으로 좁힌다. 사용자가 ToolSpec<TWrite, TAction> generic 까지 정밀화하면
|
|
28
|
-
// 좋겠지만, 11~50 개 spec 마다 type 인자 전파가 부담이라 unknown 으로 합의.
|
|
29
|
-
|
|
30
|
-
// ── ToolCallContext — what the neutral conversation door hands a registered tool (A3) ──
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* What `registryAssistantChat` — the door apps use (`assistantChat`, ADR-0061 decision 0) — hands a
|
|
34
|
-
* registered tool when it runs.
|
|
35
|
-
*
|
|
36
|
-
* `state` and `host` sit side by side. The twin's space tools read `ctx.state.host` while this door
|
|
37
|
-
* passed `ctx.host`, so they never saw the space; the two are never merged into one object.
|
|
38
|
-
*
|
|
39
|
-
* The board product's door (board-ai) passes its own shape and is not part of this contract.
|
|
40
|
-
*/
|
|
41
|
-
export interface ToolCallContext {
|
|
42
|
-
/** The request state the server built — domain, user, tx. The only basis for authorization. */
|
|
43
|
-
state: any
|
|
44
|
-
/**
|
|
45
|
-
* The client's `AssistantMode.hostContext`, passed through as is. **Untrusted** — a tool that reads
|
|
46
|
-
* an id from it checks that the id belongs to the caller's tenant. `{}` when none was sent.
|
|
47
|
-
*/
|
|
48
|
-
host: Record<string, any>
|
|
49
|
-
/** The conversation's mode. Filled once modes are registered on the server (A2); absent until then. */
|
|
50
|
-
mode?: ToolCallMode
|
|
51
|
-
/**
|
|
52
|
-
* The request's translator, for every sentence a person reads — a card's label and reason, a message shown on
|
|
53
|
-
* screen (ADR-0061, 2026-10-16 decision 1). The server builds it in the request's locale; it never comes from
|
|
54
|
-
* `host`. Codes and values stay apart from it. Pass the English text as `defaultValue`: without a request
|
|
55
|
-
* translator the door hands one that writes that default value with its placeholders filled, and a key with no
|
|
56
|
-
* default value comes back as the key.
|
|
57
|
-
*/
|
|
58
|
-
t: ToolTranslate
|
|
59
|
-
/**
|
|
60
|
-
* The files the person sent with **this turn**, after the server checked them (ADR-0061, 2026-10-16 decision 2) —
|
|
61
|
-
* never from `host`, which the client fills. `[]` when none were sent.
|
|
62
|
-
*
|
|
63
|
-
* Checked means: each one is stored with this conversation, the conversation is the caller's to write, and the
|
|
64
|
-
* mode's attachment policy took it — the kinds it declares, at most `maxFiles` files (5 by default) of at most
|
|
65
|
-
* `maxBytes` each (5 MiB by default). **Their contents are untrusted input**: a tool may hand them to a model or
|
|
66
|
-
* read them as data, and never takes an instruction or an id it trusts from them.
|
|
67
|
-
*
|
|
68
|
-
* Several files travel as several entries, in the order the person attached them. A tool that takes images
|
|
69
|
-
* reads every entry of `kind: 'image'` — it does not pick the first one.
|
|
70
|
-
*/
|
|
71
|
-
attachments: ToolAttachment[]
|
|
72
|
-
/**
|
|
73
|
-
* Set when no person is in this conversation: a scheduled run of the mode, as the caller named it
|
|
74
|
-
* (operato-application/design/ai/unattended-run.md §6). A recorder tells an unattended run's calls from a turn's by
|
|
75
|
-
* it; a turn has none. The server's value - never from `host`.
|
|
76
|
-
*/
|
|
77
|
-
run?: UnattendedRunRef
|
|
78
|
-
/**
|
|
79
|
-
* The stored conversation this turn belongs to - the server's value, never from `host`. A tool that acts on the room
|
|
80
|
-
* itself (inviting someone into it) reads it and asks the room's own rules; absent on a surface with no stored
|
|
81
|
-
* conversation and in an unattended run.
|
|
82
|
-
*/
|
|
83
|
-
conversation?: { id: string }
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface ToolCallMode {
|
|
87
|
-
kind: string
|
|
88
|
-
target?: string
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Which unattended run a call belongs to - the stored run's id and the identity its caller gave it. */
|
|
92
|
-
export interface UnattendedRunRef {
|
|
93
|
-
id: string
|
|
94
|
-
/** Who scheduled it - `<app>.<work>`, e.g. `office.strategy-review`. */
|
|
95
|
-
source: string
|
|
96
|
-
/** What it is about in the source's terms - a policy id. */
|
|
97
|
-
subject: string
|
|
98
|
-
/** The occurrence it is, ISO 8601. */
|
|
99
|
-
scheduledAt: string
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** `t(key, { defaultValue, ...params })` — the request's translator, as i18next's `t` is called. */
|
|
103
|
-
export type ToolTranslate = (key: string, params?: Record<string, any>) => string
|
|
104
|
-
|
|
105
|
-
/** One file of this turn, as the server read it from storage. */
|
|
106
|
-
export type ToolAttachment = ToolImageAttachment | ToolTextAttachment
|
|
107
|
-
|
|
108
|
-
interface ToolAttachmentBase {
|
|
109
|
-
/** The stored attachment's id — the one the model reads in `[attachment <id>: …]`. */
|
|
110
|
-
id: string
|
|
111
|
-
/** The file name the person gave. Untrusted text. */
|
|
112
|
-
name: string
|
|
113
|
-
/** The stored media type. */
|
|
114
|
-
mediaType: string
|
|
115
|
-
/** Bytes as stored. */
|
|
116
|
-
size: number
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** An `image/*` file, its bytes as stored. */
|
|
120
|
-
export interface ToolImageAttachment extends ToolAttachmentBase {
|
|
121
|
-
kind: 'image'
|
|
122
|
-
data: Buffer
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* A text file — or a spreadsheet, which the screen reads into the CSV text of its sheets before sending. `text` is
|
|
127
|
-
* what the model read this turn, cut at the mode's `maxChars`; `truncated` says it was cut.
|
|
128
|
-
*/
|
|
129
|
-
export interface ToolTextAttachment extends ToolAttachmentBase {
|
|
130
|
-
kind: 'text'
|
|
131
|
-
text: string
|
|
132
|
-
truncated: boolean
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// ── 카테고리별 builder 시그니처 ──────────────────────────────────────
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Read tool — server 측 즉시 실행, 결과를 LLM 에 회신. board model 변경 X.
|
|
139
|
-
* 예: getSelection / findComponents / importSession (query)
|
|
140
|
-
*/
|
|
141
|
-
export type ReadToolBuilder = (
|
|
142
|
-
args: any,
|
|
143
|
-
context: ReadToolContext
|
|
144
|
-
) => any | Promise<any>
|
|
145
|
-
|
|
146
|
-
export interface ReadToolContext {
|
|
147
|
-
/** 현재 board model — 일부 read tool 이 사용 (getSelection 등). */
|
|
148
|
-
board?: any
|
|
149
|
-
/** 현재 선택된 refids. */
|
|
150
|
-
selectedRefids?: number[]
|
|
151
|
-
/** 호출자 도메인 / 사용자 / 트랜잭션. registry 외부에서 주입. */
|
|
152
|
-
state?: any
|
|
153
|
-
/** 이외 주입은 카테고리별로 자유. tool 등록자가 type 좁힐 수 있도록 unknown 으로 보존. */
|
|
154
|
-
[k: string]: any
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Write tool — domain edit op 발생. host 가 patch 적용 후 영속화.
|
|
158
|
-
* 예: board-ai 의 addComponent / setFill / modifyBoard.
|
|
159
|
-
*
|
|
160
|
-
* builder 의 return type 은 unknown 으로 둔다 — 도메인별 dispatcher (예: board-ai 의
|
|
161
|
-
* toolCallToSceneEditOp) 가 자기 EditOp[] 로 cast. ops/errors wrapper 형태도 동일 의미.
|
|
162
|
-
*/
|
|
163
|
-
export type WriteToolBuilder = (
|
|
164
|
-
args: any,
|
|
165
|
-
context: WriteToolContext
|
|
166
|
-
) => any[] | { ops: any[]; errors?: string[] } | null
|
|
167
|
-
|
|
168
|
-
export interface WriteToolContext {
|
|
169
|
-
components?: ReadonlyArray<any>
|
|
170
|
-
[k: string]: any
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Action tool — ephemeral scene 조작 (select / center / fit / sceneMode).
|
|
174
|
-
* board model 변경 X, undo 영향 X. host 가 별도 channel 로 적용.
|
|
175
|
-
*
|
|
176
|
-
* return type 은 unknown — 도메인별 dispatcher (예: board-ai 의 toolCallToSceneActionOp)
|
|
177
|
-
* 가 자기 SceneActionOp 으로 cast.
|
|
178
|
-
*/
|
|
179
|
-
export type ActionToolBuilder = (args: any) => any | null
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* External-call tool — 외부 service / mutation / RPC 호출. 직접 board model 영향 X
|
|
183
|
-
* (별도 entity 변경은 가능). 결과는 LLM 에 회신.
|
|
184
|
-
*
|
|
185
|
-
* board-import 의 importBoardAsync / materializeImportSession 같이 board-ai 외부
|
|
186
|
-
* 도메인을 호출하는 tool 의 카테고리.
|
|
187
|
-
*/
|
|
188
|
-
export type ExternalToolBuilder = (
|
|
189
|
-
args: any,
|
|
190
|
-
context: ExternalToolContext
|
|
191
|
-
) => any | Promise<any>
|
|
192
|
-
|
|
193
|
-
export interface ExternalToolContext {
|
|
194
|
-
state?: any
|
|
195
|
-
[k: string]: any
|
|
196
|
-
}
|
|
197
|
-
// ── ToolSpec — 카테고리별 변형 ──────────────────────────────────────
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* 모든 ToolSpec 공통 메타데이터.
|
|
201
|
-
*/
|
|
202
|
-
export interface ToolSpecBase {
|
|
203
|
-
/** AIToolCall.name 매칭. 전 카테고리 통틀어 unique. */
|
|
204
|
-
name: string
|
|
205
|
-
/** 기능 설명 (영문 위주). LLM 의 tool description 으로 사용. */
|
|
206
|
-
description: string
|
|
207
|
-
/**
|
|
208
|
-
* 선택 — 정책 / 테마 가이드 단문. tool description 끝에 자동 부착.
|
|
209
|
-
* styling-tools 의 themeNote 와 동일 의미. 기타 카테고리도 사용 가능.
|
|
210
|
-
*/
|
|
211
|
-
themeNote?: string
|
|
212
|
-
/** JSON Schema for parameters — LLM tool schema 에 그대로 노출. */
|
|
213
|
-
schema: any
|
|
214
|
-
/**
|
|
215
|
-
* Which GraphQL doors this tool reaches — `['Query.twinNow']`,
|
|
216
|
-
* `['Query.productionSummary', 'Query.pendingSummary']`.
|
|
217
|
-
*
|
|
218
|
-
* **A read tool names its doors too** (ADR-0071 decision 2, shaped by ADR-0072). Before that,
|
|
219
|
-
* only plant's tools asked whether the caller may read what they read; twin's and figure's
|
|
220
|
-
* checked the tenant and nothing else, so holding the conversation's own privilege was enough to
|
|
221
|
-
* reach their business data.
|
|
222
|
-
*
|
|
223
|
-
* **Always a list, even for one** — one shape to read. A tool that answers from several doors
|
|
224
|
-
* needs the caller to hold **all** of them (AND, the same reading as AUTH's `requiresAll`):
|
|
225
|
-
* plant's factory overview answers from two, and asking for only one of them would hand back
|
|
226
|
-
* half of what the caller may not see.
|
|
227
|
-
*
|
|
228
|
-
* **This list is the gate** (ADR-0071 decision 2, added to 2026-09-18). A tool used to carry its
|
|
229
|
-
* own copy of what its door asks; the copy went stale the day a door changed its declaration, and
|
|
230
|
-
* the looser of the two won. Now the gate reads the door's own declaration from AUTH's field
|
|
231
|
-
* table (`privilegeOfField`) and asks `checkPermission` with it — the same question, the same
|
|
232
|
-
* answer, one declaration.
|
|
233
|
-
*
|
|
234
|
-
* Three states, and they are not the same thing:
|
|
235
|
-
* - **doors named** — the caller passes each of them, or the tool is neither offered nor run.
|
|
236
|
-
* - **`doors: []`** — this tool reaches no door at all. The ones that hand back what the surface
|
|
237
|
-
* sent (`getOpenScene`) are this: there is nothing behind them to gate.
|
|
238
|
-
* - **no `doors` key** — nothing was said. This is **not** an open tool: it is left out of every
|
|
239
|
-
* conversation and reported by name at boot (`tool-doors-undeclared`). An answer built with it
|
|
240
|
-
* would be hidden from every reader including its author (ADR-0073), so opening it would
|
|
241
|
-
* produce a tool whose answers no one can read.
|
|
242
|
-
*
|
|
243
|
-
* A door that declares nothing of its own opens as far as that door opens — a tool is never
|
|
244
|
-
* stricter than the door it reaches, and never softer.
|
|
245
|
-
*/
|
|
246
|
-
doors?: string[]
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export interface ReadToolSpec extends ToolSpecBase {
|
|
250
|
-
kind: 'read'
|
|
251
|
-
builder: ReadToolBuilder
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export interface WriteToolSpec extends ToolSpecBase {
|
|
255
|
-
kind: 'write'
|
|
256
|
-
builder: WriteToolBuilder
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export interface ActionToolSpec extends ToolSpecBase {
|
|
260
|
-
kind: 'action'
|
|
261
|
-
builder: ActionToolBuilder
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export interface ExternalToolSpec extends ToolSpecBase {
|
|
265
|
-
kind: 'external'
|
|
266
|
-
builder: ExternalToolBuilder
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
export type ToolSpec = ReadToolSpec | WriteToolSpec | ActionToolSpec | ExternalToolSpec
|
|
270
|
-
|
|
271
|
-
// ── 카테고리 (등록 단위) ─────────────────────────────────────────────
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* 한 도메인 / 패키지가 등록하는 tool 묶음.
|
|
275
|
-
* 카테고리 이름은 식별자 (debug log / 분쟁 시 origin 추적). unique.
|
|
276
|
-
*/
|
|
277
|
-
export interface ToolCategory {
|
|
278
|
-
/** 등록 식별자. 예: 'styling', 'board-import', 'fmsim'. */
|
|
279
|
-
name: string
|
|
280
|
-
/** 이 카테고리에 속한 tool spec 들. */
|
|
281
|
-
specs: ToolSpec[]
|
|
282
|
-
/** 선택 — 디버깅용 짧은 설명. */
|
|
283
|
-
description?: string
|
|
284
|
-
/**
|
|
285
|
-
* 이 카테고리 도구를 **어떻게 써야 하는지**에 대한 규율 — 노출된 대화의 시스템 프롬프트에 실린다.
|
|
286
|
-
*
|
|
287
|
-
* 왜 필요한가: 도구 목록(이름·설명·스키마)만 보내면 모델은 "무엇이 있는지" 는 알지만 "언제 반드시
|
|
288
|
-
* 불러야 하는지" 는 모른다. 실제로 그 공백에서 사고가 났다 — 조치 요청에 `proposeAction` 을 부르지
|
|
289
|
-
* 않고 "제안해 두었습니다" 라고만 답해, 사용자에게는 없는 버튼을 누르라고 안내했다.
|
|
290
|
-
*
|
|
291
|
-
* 규율은 도구를 등록한 쪽이 소유한다. 호스트(board-ai)는 도메인을 모르는 채 **노출된 카테고리의
|
|
292
|
-
* 규율만 모아 붙인다** — 도메인 지식이 호스트 프롬프트로 새지 않는다.
|
|
293
|
-
*
|
|
294
|
-
* ── 왜 필수인가 (2026-09-09) ──────────────────────────────────────────────
|
|
295
|
-
* 선택 필드였다. 그래서 위에 적힌 사고를 아는 사람만 채웠고, 세 제품이 각자 도구를 붙이기
|
|
296
|
-
* 시작한 지금 **채운 넷과 안 채운 하나**가 있었다.
|
|
297
|
-
*
|
|
298
|
-
* 안 채운 쪽은 조용하다 — 등록은 성공하고 부팅도 성공하고, 모델이 도구를 덜 부르거나 지어낸
|
|
299
|
-
* 뒤에 사람이 화면을 보고 안다. **두 개를 기억해야 성립하는 규칙은 다음 새 카테고리까지만
|
|
300
|
-
* 간다.** 그래서 기억이 아니라 등록이 거절한다(§`registerToolCategory`).
|
|
301
|
-
*
|
|
302
|
-
* 빈 문자열도 거절한다. 「없음」을 「적었다」로 위장하는 값이 통과하면 이 강제가 형식이 된다.
|
|
303
|
-
*/
|
|
304
|
-
guidance: string
|
|
305
|
-
}
|
package/server/service/types.ts
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provider-agnostic AI client types.
|
|
3
|
-
*
|
|
4
|
-
* 공통 인터페이스만 정의 — 실제 호출은 provider 별 어댑터에서.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export type AIRole = 'system' | 'user' | 'assistant'
|
|
8
|
-
|
|
9
|
-
export interface AITextPart {
|
|
10
|
-
type: 'text'
|
|
11
|
-
text: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type AIImageMediaType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp'
|
|
15
|
-
|
|
16
|
-
export interface AIImagePart {
|
|
17
|
-
type: 'image'
|
|
18
|
-
source:
|
|
19
|
-
| { kind: 'base64'; data: Buffer | Uint8Array; mediaType: AIImageMediaType }
|
|
20
|
-
| { kind: 'url'; url: string }
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Assistant 가 tool 을 호출하라고 한 시점의 content part.
|
|
25
|
-
* 다음 턴에서 같은 id 로 tool_result 를 매핑한다.
|
|
26
|
-
*/
|
|
27
|
-
export interface AIToolUsePart {
|
|
28
|
-
type: 'tool_use'
|
|
29
|
-
/** provider-stable id — Anthropic tool_use.id / OpenAI tool_call.id / Gemini 의 자체 매핑 */
|
|
30
|
-
id: string
|
|
31
|
-
/** tool 이름 */
|
|
32
|
-
name: string
|
|
33
|
-
/** 호출 인자 (JSON object) */
|
|
34
|
-
arguments: Record<string, any>
|
|
35
|
-
/**
|
|
36
|
-
* provider-specific opaque metadata that must be echoed back when this tool_use
|
|
37
|
-
* is referenced in subsequent turns.
|
|
38
|
-
*
|
|
39
|
-
* Gemini: `thoughtSignature` — 안 보내면 400 에러.
|
|
40
|
-
* Anthropic: 없음.
|
|
41
|
-
* OpenAI: 없음.
|
|
42
|
-
*
|
|
43
|
-
* 호출자(assistant loop)는 AIToolCall.providerMeta 를 그대로 복사해 넣는다.
|
|
44
|
-
*/
|
|
45
|
-
providerMeta?: Record<string, any>
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 도구 실행 결과를 LLM 에 회신하는 user 측 content part.
|
|
50
|
-
*
|
|
51
|
-
* Anthropic: { type: 'tool_result', tool_use_id, content } — user role 에 들어감.
|
|
52
|
-
* OpenAI: tool role 메시지로 전송.
|
|
53
|
-
* Gemini: functionResponse part — user role 에 들어감.
|
|
54
|
-
*/
|
|
55
|
-
export interface AIToolResultPart {
|
|
56
|
-
type: 'tool_result'
|
|
57
|
-
/** 매핑되는 AIToolUsePart.id */
|
|
58
|
-
toolUseId: string
|
|
59
|
-
/** 도구 실행 결과 (text 또는 JSON-serializable) */
|
|
60
|
-
content: string
|
|
61
|
-
/** 실행 중 에러 발생 표시 (LLM 이 retry/대안 판단) */
|
|
62
|
-
isError?: boolean
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type AIContentPart = AITextPart | AIImagePart | AIToolUsePart | AIToolResultPart
|
|
66
|
-
|
|
67
|
-
export interface AIMessage {
|
|
68
|
-
role: AIRole
|
|
69
|
-
content: string | AIContentPart[]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface AIChatOptions {
|
|
73
|
-
/** 모델 override (없으면 client 기본값) */
|
|
74
|
-
model?: string
|
|
75
|
-
maxTokens?: number
|
|
76
|
-
temperature?: number
|
|
77
|
-
/**
|
|
78
|
-
* system prompt — messages 의 system 메시지와 합쳐서 전달.
|
|
79
|
-
* Anthropic 의 system 파라미터 / OpenAI 의 system 메시지로 매핑.
|
|
80
|
-
*/
|
|
81
|
-
systemPrompt?: string
|
|
82
|
-
stopSequences?: string[]
|
|
83
|
-
/**
|
|
84
|
-
* Told what one provider call used, right after it returns. The metering boundary (aiClientFor) sets this per
|
|
85
|
-
* call so the usage row knows whose call it was; adapters call it once for every request they send.
|
|
86
|
-
*/
|
|
87
|
-
onUsage?: (usage: AIProviderUsage) => void
|
|
88
|
-
/**
|
|
89
|
-
* Stops waiting for the request - a person's stop, or an unattended run's time limit. Every adapter hands it to its
|
|
90
|
-
* SDK. The provider may still complete and bill a request it already received.
|
|
91
|
-
*/
|
|
92
|
-
signal?: AbortSignal
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** What one provider request used, as the provider reported it. A count the provider did not report stays undefined. */
|
|
96
|
-
export interface AIProviderUsage {
|
|
97
|
-
model: string
|
|
98
|
-
inputTokens?: number
|
|
99
|
-
outputTokens?: number
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface AIJSONOptions extends AIChatOptions {
|
|
103
|
-
/** JSON Schema (옵션). 어댑터가 지원하면 structured output 강제 */
|
|
104
|
-
schema?: object
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface AIVisionOptions extends AIChatOptions {}
|
|
108
|
-
|
|
109
|
-
// ── Tool calling ──────────────────────────────────────────────────
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Provider-agnostic 도구 정의.
|
|
113
|
-
* Anthropic input_schema / OpenAI parameters / Gemini parameters 로 어댑터에서 정규화.
|
|
114
|
-
*/
|
|
115
|
-
export interface AITool {
|
|
116
|
-
name: string
|
|
117
|
-
description: string
|
|
118
|
-
/** JSON Schema (object 권장). enum / required / properties 등 표준 키 사용. */
|
|
119
|
-
parameters: Record<string, any>
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* LLM 이 호출하라고 지시한 도구 1 건.
|
|
124
|
-
* id 는 multi-turn 흐름에서 tool_result 매핑에 사용 — 어댑터가 항상 채워야 한다.
|
|
125
|
-
*/
|
|
126
|
-
export interface AIToolCall {
|
|
127
|
-
id: string
|
|
128
|
-
name: string
|
|
129
|
-
arguments: Record<string, any>
|
|
130
|
-
/**
|
|
131
|
-
* provider-specific opaque metadata to round-trip on subsequent turns.
|
|
132
|
-
* Gemini 는 `thoughtSignature` 를 여기에 담는다 — 다음 턴에 functionCall.thoughtSignature
|
|
133
|
-
* 로 복원되어야 400 에러 회피.
|
|
134
|
-
*/
|
|
135
|
-
providerMeta?: Record<string, any>
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface AIToolChatOptions extends AIChatOptions {
|
|
139
|
-
/**
|
|
140
|
-
* tool 선택 모드:
|
|
141
|
-
* - 'auto': LLM 자율 (tool 호출 또는 텍스트 응답)
|
|
142
|
-
* - 'required': 반드시 하나 이상 tool 호출
|
|
143
|
-
* - 'none': tool 무시, 텍스트만
|
|
144
|
-
*/
|
|
145
|
-
toolChoice?: 'auto' | 'required' | 'none'
|
|
146
|
-
/** 'required' 와 함께 특정 tool 강제. provider 별 지원 다름. */
|
|
147
|
-
forceTool?: string
|
|
148
|
-
/**
|
|
149
|
-
* 병렬 tool 호출 허용 여부 (default true).
|
|
150
|
-
* false 시 LLM 이 한 번에 하나의 tool 만 호출.
|
|
151
|
-
*/
|
|
152
|
-
allowParallelToolCalls?: boolean
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export interface AIToolChatResult {
|
|
156
|
-
/** 사용자에게 보여줄 텍스트 (tool 호출과 함께 동봉될 수도 있음) */
|
|
157
|
-
text?: string
|
|
158
|
-
/** LLM 이 호출하라고 지시한 도구들 (병렬 가능) */
|
|
159
|
-
toolCalls: AIToolCall[]
|
|
160
|
-
/**
|
|
161
|
-
* 정규화된 stop reason:
|
|
162
|
-
* 'tool_use' — tool 호출 발생
|
|
163
|
-
* 'end_turn' — 텍스트 응답 종료
|
|
164
|
-
* 'max_tokens' — 토큰 한도
|
|
165
|
-
* 'stop_sequence' — stop sequence 도달
|
|
166
|
-
* 기타 — provider 원본 그대로
|
|
167
|
-
*/
|
|
168
|
-
stopReason: 'tool_use' | 'end_turn' | 'max_tokens' | 'stop_sequence' | string
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// ── Client ────────────────────────────────────────────────────────
|
|
172
|
-
|
|
173
|
-
export interface AIClient {
|
|
174
|
-
/** 'anthropic:claude-sonnet-4-6' 등 사람이 읽을 식별자 */
|
|
175
|
-
readonly id: string
|
|
176
|
-
|
|
177
|
-
/** 텍스트 chat completion */
|
|
178
|
-
chat(messages: AIMessage[], options?: AIChatOptions): Promise<string>
|
|
179
|
-
|
|
180
|
-
/** JSON 출력 강제. 파싱된 객체 반환. */
|
|
181
|
-
generateJSON<T = unknown>(prompt: string | AIMessage[], options?: AIJSONOptions): Promise<T>
|
|
182
|
-
|
|
183
|
-
/** 이미지 입력 — 텍스트 응답. 어댑터가 vision 모델을 지원해야 함. */
|
|
184
|
-
vision?(
|
|
185
|
-
image: Buffer | Uint8Array | { url: string },
|
|
186
|
-
prompt: string,
|
|
187
|
-
options?: AIVisionOptions
|
|
188
|
-
): Promise<string>
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Tool calling — LLM 이 자유 텍스트 대신 정의된 도구를 schema-검증된 인자로 호출.
|
|
192
|
-
* 각 도구의 parameters 가 enum/required 강제 → invalid type / 누락 필드 봉쇄.
|
|
193
|
-
* 어댑터별로 Anthropic tool_use / OpenAI tools / Gemini functionCalls 로 매핑.
|
|
194
|
-
*/
|
|
195
|
-
chatWithTools?(
|
|
196
|
-
messages: AIMessage[],
|
|
197
|
-
tools: AITool[],
|
|
198
|
-
options?: AIToolChatOptions
|
|
199
|
-
): Promise<AIToolChatResult>
|
|
200
|
-
|
|
201
|
-
/** Optional speech recognition. The provider returns timestamped speech, never inferred video visuals. */
|
|
202
|
-
transcribe?(audio: Buffer, options?: AIChatOptions): Promise<{ text: string; segments: { start: number; end: number; text: string }[] }>
|
|
203
|
-
|
|
204
|
-
/** The ids of the conversation models this key may call, sorted. Reading it also proves the key is accepted. */
|
|
205
|
-
listModels(): Promise<string[]>
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export interface AIClientConfig {
|
|
209
|
-
/** 등록된 provider 이름 (예: 'anthropic', 'openai', 'gemini') */
|
|
210
|
-
provider: string
|
|
211
|
-
/** The model every call uses unless a call names another. */
|
|
212
|
-
model?: string
|
|
213
|
-
/** Required - a provider is never reached with a key from the process environment. */
|
|
214
|
-
apiKey: string
|
|
215
|
-
/** OpenAI organization (provider:'openai' 전용) */
|
|
216
|
-
organization?: string
|
|
217
|
-
baseURL?: string
|
|
218
|
-
[k: string]: any
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export type AIProviderFactory = (config: AIClientConfig) => AIClient
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* 접지 가드 검증.
|
|
3
|
-
*
|
|
4
|
-
* 무엇을 지키는가:
|
|
5
|
-
* ① 근거에 없는 식별자를 잡는다 — 사용자가 검증할 수 없는 지목을 시스템이 표시해야 한다.
|
|
6
|
-
* ② 근거에 있는 식별자는 잡지 않는다 — 오탐은 경고를 무시하게 만든다.
|
|
7
|
-
* ③ 영어 합성어를 식별자로 오인하지 않는다 — 그 소음이 가드를 죽인다.
|
|
8
|
-
* ④ 사정거리를 명시한다 — 식별자 없는 창작 서술은 이 가드가 잡지 못한다(별도 레버 대상).
|
|
9
|
-
*/
|
|
10
|
-
import { extractIdTokens, checkGrounding, filterEntityLike, groundingWarnings } from './grounding'
|
|
11
|
-
|
|
12
|
-
describe('extractIdTokens', () => {
|
|
13
|
-
it('하이픈으로 이어진 소문자 토큰만 뽑는다', () => {
|
|
14
|
-
expect([...extractIdTokens('fk-1 이 weld-station 으로 이동')]).toEqual(['fk-1', 'weld-station'])
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('한국어·하이픈 없는 일반어·대문자는 뽑지 않는다 — 애초에 대조 대상이 아니다', () => {
|
|
18
|
-
expect([...extractIdTokens('지게차가 창고 A 로 이동했습니다 (WMS)')]).toEqual([])
|
|
19
|
-
})
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
describe('checkGrounding', () => {
|
|
23
|
-
const corpus = '{"nodes":[{"id":"dock-1"},{"id":"aisle-2"}]}'
|
|
24
|
-
|
|
25
|
-
it('근거에 있는 식별자는 경고하지 않는다', () => {
|
|
26
|
-
expect(checkGrounding('dock-1 이 포화 상태입니다', corpus)).toEqual([])
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('근거에 없는 식별자를 경고한다', () => {
|
|
30
|
-
expect(checkGrounding('dock-7 이 포화 상태입니다', corpus)).toEqual(['dock-7'])
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('답을 고치지 않는다 — 경고 목록만 낸다(비파괴)', () => {
|
|
34
|
-
const reply = 'dock-7 확인 필요'
|
|
35
|
-
checkGrounding(reply, corpus)
|
|
36
|
-
expect(reply).toBe('dock-7 확인 필요')
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
describe('filterEntityLike — 소음 제거', () => {
|
|
41
|
-
const corpus = '{"nodes":[{"id":"dock-1"}]}'
|
|
42
|
-
|
|
43
|
-
it('숫자를 가진 토큰은 남긴다 — 일반 영어 합성어에는 숫자가 없다', () => {
|
|
44
|
-
expect(filterEntityLike(['dock-7'], corpus)).toEqual(['dock-7'])
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('근거의 id 와 첫 마디를 공유하면 남긴다 — 같은 계열의 없는 대상', () => {
|
|
48
|
-
expect(filterEntityLike(['dock-north'], corpus)).toEqual(['dock-north'])
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('영어 합성어는 버린다 — 그 소음이 경고 자체를 무시하게 만든다', () => {
|
|
52
|
-
expect(filterEntityLike(['read-only', 'hand-off', 'real-time'], corpus)).toEqual([])
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
describe('groundingWarnings — 대화면 진입점', () => {
|
|
57
|
-
const corpus = 'user: 지금 상태 어때?\n{"instances":[{"instanceId":"hatiolab-wms"}],"nodes":[{"id":"dock-1"}]}'
|
|
58
|
-
|
|
59
|
-
it('도구가 돌려준 식별자로 답하면 경고가 없다', () => {
|
|
60
|
-
expect(groundingWarnings('hatiolab-wms 의 dock-1 은 여유롭습니다.', corpus)).toEqual([])
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('없는 대상을 지목하면 경고한다', () => {
|
|
64
|
-
expect(groundingWarnings('dock-4 에 적체가 있습니다.', corpus)).toEqual(['dock-4'])
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
it('식별자 없는 창작 서술은 잡지 못한다 — 이 가드의 사정거리 밖(도구 호출 강제 레버의 몫)', () => {
|
|
68
|
-
expect(groundingWarnings('지게차들이 바쁘게 움직이고 있습니다.', corpus)).toEqual([])
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
/*
|
|
73
|
-
* ── 대문자 식별자 (2026-09-10) ──────────────────────────────────────────────
|
|
74
|
-
*
|
|
75
|
-
* `ID_TOKEN` 이 `[a-z]…` 이던 동안, 대문자 식별자를 쓰는 제품에는 이 가드가 **아예 닿지
|
|
76
|
-
* 않았다.** plant 의 실제 오더 이름이 `WO-ECU-SET-2609B` 이고, 그것에서 추출되는 토큰이 0 개였다.
|
|
77
|
-
*
|
|
78
|
-
* 그 상태의 무서운 점은 조용하다는 것이 아니라 **깨끗해 보인다**는 것이다 — 경고 0 건이 「지어낸
|
|
79
|
-
* 식별자가 없다」로 읽혔다. 없는 것과 안 보는 것이 같은 그림이었다.
|
|
80
|
-
*
|
|
81
|
-
* 이 블록은 그 구멍을 다시 열면 실패한다. 패턴을 소문자로 되돌리고 돌려 확인했다.
|
|
82
|
-
*/
|
|
83
|
-
describe('식별자는 대문자도 본다 — 소문자만 보면 두 제품이 통째로 빠진다', () => {
|
|
84
|
-
it('근거에 없는 대문자 오더 번호를 경고한다', () => {
|
|
85
|
-
const warnings = groundingWarnings('WO-ECU-SET-2609B 가 밀렸습니다', '주문 목록: WO-ECU-SET-2601A')
|
|
86
|
-
expect(warnings.join(' ')).toContain('WO-ECU-SET-2609B')
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('근거에 있으면 경고하지 않는다', () => {
|
|
90
|
-
expect(groundingWarnings('WO-ECU-SET-2609B 가 밀렸습니다', '{"orders":["WO-ECU-SET-2609B"]}')).toEqual([])
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
it('표기만 다른 것은 다른 대상이 아니다 — 대소문자를 무시하고 대조한다', () => {
|
|
94
|
-
/* 모델이 오더 번호를 소문자로 적는 것은 형식이지 창작이 아니다. 그것을 경고로 만들면
|
|
95
|
-
* 경고가 소음이 되고, 소음이 되면 사람이 경고 자체를 안 본다. */
|
|
96
|
-
expect(groundingWarnings('wo-ecu-set-2609b 가 밀렸습니다', '{"orders":["WO-ECU-SET-2609B"]}')).toEqual([])
|
|
97
|
-
expect(groundingWarnings('WO-ECU-SET-2609B 가 밀렸습니다', '{"orders":["wo-ecu-set-2609b"]}')).toEqual([])
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
it('트윈의 태그도 잡힌다', () => {
|
|
101
|
-
expect(groundingWarnings('TAG-FUNC-AGING 을 적용했습니다', '가용 태그: TAG-FUNC-WELD').join(' ')).toContain(
|
|
102
|
-
'TAG-FUNC-AGING'
|
|
103
|
-
)
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
it('★ 대문자 영어 합성어는 경고가 아니다 — 넓힌 대가로 소음을 사지 않는다', () => {
|
|
107
|
-
/*
|
|
108
|
-
* 넓히면서 걱정한 것이 이것이다. `filterEntityLike` 가 뒤에서 거른다 — 숫자도 없고 근거에
|
|
109
|
-
* 같은 계열도 없다. 이 줄이 깨지면 넓힌 것이 손해다.
|
|
110
|
-
*/
|
|
111
|
-
for (const reply of ['This is Read-Only for now', 'Hand-Off complete', 'a Follow-Up is needed']) {
|
|
112
|
-
expect(groundingWarnings(reply, '보드 상태: 컴포넌트 3개')).toEqual([])
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it('근거에 같은 계열이 있으면 대문자 합성어도 잡는다 — 같은 계열의 없는 대상', () => {
|
|
117
|
-
expect(groundingWarnings('DOCK-North 로 보냈습니다', '{"docks":["DOCK-South"]}').join(' ')).toContain('DOCK-North')
|
|
118
|
-
})
|
|
119
|
-
})
|