mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-21 15:40:54 +08:00
Compare commits
37
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
752d0cfab4 | ||
|
|
79119ae9bd | ||
|
|
b3b9334dc8 | ||
|
|
33e8d79426 | ||
|
|
42e8d3554d | ||
|
|
caa38f6ca8 | ||
|
|
0d85fc9b06 | ||
|
|
40a43580fe | ||
|
|
5def7bf57e | ||
|
|
268693066a | ||
|
|
0ffb0a68c4 | ||
|
|
892d1330f6 | ||
|
|
11adad32ce | ||
|
|
49c5e8fa8a | ||
|
|
f6f9575b19 | ||
|
|
280e99eace | ||
|
|
e2ca0118e7 | ||
|
|
1e9079267b | ||
|
|
aa8ba54efb | ||
|
|
5e1c55db4d | ||
|
|
5679618ea7 | ||
|
|
9ab895f2b7 | ||
|
|
f758b4d964 | ||
|
|
c5cb1afad7 | ||
|
|
3feeb37a3a | ||
|
|
bbe95d085b | ||
|
|
9be6b76420 | ||
|
|
ada0092168 | ||
|
|
2d6d5c4e2b | ||
|
|
12f0ec0432 | ||
|
|
2ff2fc59ac | ||
|
|
2db355389a | ||
|
|
6e906b4920 | ||
|
|
594d1918fd | ||
|
|
84c77021c4 | ||
|
|
5e979f102a | ||
|
|
cc465be782 |
@@ -21,6 +21,8 @@ ARTEX_LLM_PROVIDER=
|
||||
ARTEX_LLM_MODEL=
|
||||
ARTEX_LLM_BASE_URL=
|
||||
ARTEX_LLM_PROXY=
|
||||
# Allow the UI model list to reach a local Ollama, e.g. host.docker.internal:11434
|
||||
ARTEX_LLM_PRIVATE_ENDPOINTS=
|
||||
|
||||
# Untrusted-output boundary. Frames every tool output between nonce-tagged markers so
|
||||
# the model treats it as data, not instructions. On by default (unset or empty = on);
|
||||
|
||||
@@ -39,8 +39,6 @@ jobs:
|
||||
# - TestGraphOverviewExpandsAssociatedCompanyScope,
|
||||
# TestCaptureApprovalLifecycle: fail on unmodified upstream code with a
|
||||
# fresh database.
|
||||
# - TestSideUsageRecordedOnceOnConsumerCancellation: concurrency/cancellation
|
||||
# test that passes locally but is timing-sensitive on 2-core CI runners.
|
||||
# They now skip themselves in code (t.Skip with a pointer to the issue).
|
||||
- name: go test
|
||||
# -p 1: package test suites share the single postgres service; running
|
||||
|
||||
@@ -53,6 +53,7 @@ All notable changes to this project are documented in this file. The format is b
|
||||
|
||||
### Fixed
|
||||
|
||||
- **LLM usage status on early stream exit**: when a consumer stops reading a stream before `message_stop`, the recorder now stores the `llm_usage` row as `error` at that point, whether or not the context was cancelled, instead of inferring the status from `ctx.Err()` in a deferred call. `TestSideUsageRecordedOnceOnConsumerCancellation` runs again (follow-up to #9).
|
||||
- **Workspace and skill symlink confinement**: workspace file operations, the skill file APIs and the skill loader resolve symlinks in every path component and refuse a target outside their root, so a link planted in the workspace or a skill directory cannot expose another file.
|
||||
- **Target gate behind proxies**: a target approval is name-only whenever a proxy is in the path, including the recording proxy, the global egress proxy and a custom tool's own proxy, so the gate never claims an IP binding the proxy does not enforce.
|
||||
- **Remote MCP response bound**: Streamable HTTP JSON-RPC bodies and SSE data payloads are refused above 8 MiB, so a remote MCP server cannot force an unbounded decode.
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# Contributing
|
||||
|
||||
## First contribution
|
||||
|
||||
- **Share feedback.** Check [open issues](https://github.com/BaaRai/ARTEX/issues) for the same problem or proposal and add any new details there. For a new idea, explain what you were trying to do and what would make it easier.
|
||||
- **Report a problem.** Include a short reproduction and the relevant environment. For a UI issue, a sanitized screenshot and the browser version can help. Remove credentials, private URLs, and sensitive task data before posting.
|
||||
- **Report a security issue.** Do not open a public issue for a vulnerability; follow [SECURITY.md](SECURITY.md) to report it privately.
|
||||
- **Send a small change.** A documentation correction or a focused UI improvement is a good place to start. Check [open pull requests](https://github.com/BaaRai/ARTEX/pulls) for overlapping work and refer to the relevant issue in your PR so readers can find the discussion.
|
||||
|
||||
## Pull requests
|
||||
|
||||
- **At most 7 open pull requests per contributor.** The repository enforces this with GitHub's pull request creation limit, drafts included: when you reach it, close or merge one before opening another. Review is manual, one change at a time, so a larger batch makes the queue unmanageable and slows everyone down, including you. If you have more changes queued, open one issue that lists them and wait for the current ones to be reviewed.
|
||||
|
||||
@@ -545,6 +545,25 @@ a trusted peer can claim any client address.
|
||||
|
||||
## Operations
|
||||
|
||||
### Troubleshooting an empty tool call
|
||||
|
||||
In the task's session transcript, expand the affected tool call and compare **Command** and
|
||||
**Output**. The `UNTRUSTED_OUTPUT` markers identify the boundary around tool output. They are
|
||||
expected and should stay enabled while troubleshooting.
|
||||
|
||||
- **Command shows `{}`.** The recorded tool input is an empty JSON object. For a tool that
|
||||
requires a command, this means its command argument was missing. Check which model and version
|
||||
produced the call.
|
||||
- **Command shows `(empty)` or `(failed to load)`.** The transcript has no input detail to display
|
||||
or could not fetch it. If the session record contains a command, include that discrepancy in a
|
||||
report.
|
||||
- **Output shows `[]`.** This is the recorded result body. Check the row's success or failure
|
||||
indicator and its input separately before drawing conclusions about what ran.
|
||||
|
||||
For a recurring problem, share the ARTEX version or commit, the model and version, and a sanitized
|
||||
excerpt of the affected input and result. Remove credentials, target data, and other sensitive
|
||||
content before sharing.
|
||||
|
||||
### Backups
|
||||
|
||||
`scripts/backup.sh` dumps the Postgres database (and optionally the data directory) with
|
||||
|
||||
@@ -101,6 +101,14 @@ func guardPanic(t actool.CoreTool) actool.CoreTool { return &guardedTool{CoreToo
|
||||
|
||||
type guardedTool struct{ actool.CoreTool }
|
||||
|
||||
// AcceptsRawInput forwards the wrapped tool's opt-out of the harness schema
|
||||
// check, as overriddenTool does: this wrapper is the one the harness sees, and
|
||||
// the embedded interface alone would hide the opt-out from its type assertion.
|
||||
func (g *guardedTool) AcceptsRawInput() bool {
|
||||
r, ok := g.CoreTool.(interface{ AcceptsRawInput() bool })
|
||||
return ok && r.AcceptsRawInput()
|
||||
}
|
||||
|
||||
func (g *guardedTool) Call(ctx context.Context, in json.RawMessage, tc *actool.ToolContext) (res actool.Result, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestTaskScopeLabelIsHonest(t *testing.T) {
|
||||
// denominator and list_untested_assets.
|
||||
func TestAutoScopeOutsideDeclaredRootExcluded(t *testing.T) {
|
||||
d := testDB(t)
|
||||
defer d.Close()
|
||||
t.Cleanup(func() { _ = d.Close() })
|
||||
|
||||
stamp := time.Now().UnixNano()
|
||||
declared := fmt.Sprintf("app.f8-%d.invalid", stamp)
|
||||
|
||||
@@ -194,7 +194,7 @@ func companiesName(t *testing.T, companies *db.CompanyStore, companyID int64) st
|
||||
|
||||
func TestBlackboardToolsReadDirectSources(t *testing.T) {
|
||||
d := testDB(t)
|
||||
defer d.Close()
|
||||
t.Cleanup(func() { _ = d.Close() })
|
||||
|
||||
grand, err := d.CreateTask("grand", "grand goal", nil, 0, 0)
|
||||
if err != nil {
|
||||
@@ -378,7 +378,7 @@ func TestBlackboardToolsReadDirectSources(t *testing.T) {
|
||||
// model which ids it deferred, after de-duplicating and dropping invalid ids.
|
||||
func TestGetWorkerTraceStepIDsDegradeGracefully(t *testing.T) {
|
||||
d := testDB(t)
|
||||
defer d.Close()
|
||||
t.Cleanup(func() { _ = d.Close() })
|
||||
|
||||
task, err := d.CreateTask("trace-cap", "goal", nil, 0, 0)
|
||||
if err != nil {
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
// write happens even when the stored flag is off, which is the outage behaviour.
|
||||
func TestCoverageReadFailureKeepsToolsAndWritesAutoScope(t *testing.T) {
|
||||
d := testDB(t)
|
||||
defer d.Close()
|
||||
t.Cleanup(func() { _ = d.Close() })
|
||||
off := false
|
||||
task, err := d.CreateTaskWithOptions("coverage outage", "goal", db.TaskCreateOptions{CoverageEnabled: &off})
|
||||
if err != nil {
|
||||
|
||||
@@ -115,10 +115,9 @@ func TestRecordFactAssetAliases(t *testing.T) {
|
||||
func TestRecordFactAssetAliasSchema(t *testing.T) {
|
||||
schema := NewToolSet(nil, "").recordFact().InputSchema()
|
||||
props := schema["properties"].(map[string]any)
|
||||
for _, name := range []string{"asset_ids", "tested_asset_ids"} {
|
||||
if props[name] == nil {
|
||||
t.Fatalf("single schema missing %s", name)
|
||||
}
|
||||
// Facts-only contract: the alias lives on the items.
|
||||
if len(props) != 1 || props["facts"] == nil {
|
||||
t.Fatalf("top level must hold facts only: %v", props)
|
||||
}
|
||||
item := props["facts"].(map[string]any)["items"].(map[string]any)
|
||||
itemProps, _ := item["properties"].(map[string]any)
|
||||
|
||||
+88
-58
@@ -4,10 +4,12 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Match strings.TrimSpace, including Unicode whitespace, in the published schema.
|
||||
const factWhitespace = "\t\n\v\f\r \u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000"
|
||||
const factWhitespace = "\t\n\v\f\r \u0085 -
"
|
||||
|
||||
func factAssetIDSchema() map[string]any {
|
||||
return map[string]any{
|
||||
@@ -16,10 +18,13 @@ func factAssetIDSchema() map[string]any {
|
||||
}
|
||||
}
|
||||
|
||||
// factItemSchema is one fact: the shape of every facts[] item. It is also the
|
||||
// shape of the legacy single-fact call (fields at the top level, no facts),
|
||||
// which the handler still accepts but the published schema no longer shows.
|
||||
func factItemSchema() map[string]any {
|
||||
schema := obj(map[string]any{
|
||||
"summary": str("Required on every fact: a non-empty one-sentence summary of this conclusion. Batch items do not inherit summary from the top level."),
|
||||
"intent_id": idp("The intent that produced this fact; only this field inherits from the top level in a batch."),
|
||||
"summary": str("Required: a non-empty one-sentence summary of this conclusion."),
|
||||
"intent_id": idp("The intent that produced this fact. Omit it to link the fact to the intent this worker is running; a batch may name a different intent per item."),
|
||||
"detail": str("Details of this fact, including all related observations."),
|
||||
"evidence": str("One line of key evidence: the command and the most proving output lines. Put longer output in detail."),
|
||||
"confidence": str("observed (seen directly in output) | inferred (inferred from phenomena). Label negative conclusions honestly."),
|
||||
@@ -34,68 +39,67 @@ func factItemSchema() map[string]any {
|
||||
return schema
|
||||
}
|
||||
|
||||
// recordFactFactsDescription documents the only top-level property of
|
||||
// record_fact. The wording tells a model that tends to fill every declared
|
||||
// property that there is nothing else to fill.
|
||||
const recordFactFactsDescription = "The facts to record, usually exactly one. Every item is a complete fact with its own summary. This is the only top-level property: never send summary, detail, evidence, confidence, source, intent_id or asset ids beside facts. Returned ids match item order; retry only failed indices."
|
||||
|
||||
// recordFactContractNote is appended to the record_fact description: the one
|
||||
// call shape the model is given.
|
||||
const recordFactContractNote = "\n★Call shape: exactly {\"facts\":[{...}]} with one item per distinct conclusion (usually one item). Each item carries its own summary, detail, evidence, confidence, source, asset_ids and, when it differs from the intent you are running, intent_id. Nothing else at the top level; a top-level fact field beside facts is refused and nothing is written."
|
||||
|
||||
// RecordFactContractNote exposes the text to the server's one-time refresh.
|
||||
func RecordFactContractNote() string { return recordFactContractNote }
|
||||
|
||||
// recordFactSchema is the published input contract: facts[] and nothing else.
|
||||
// Providers reject root-level anyOf, and the earlier contract (fact fields at
|
||||
// the top level beside facts[]) made models fill both; the handler alone keeps
|
||||
// the legacy shapes alive.
|
||||
func recordFactSchema() map[string]any {
|
||||
props := factItemSchema()["properties"].(map[string]any)
|
||||
props["facts"] = map[string]any{
|
||||
"type": "array", "minItems": 1, "items": factItemSchema(),
|
||||
"description": "A non-empty batch of complete facts. Every item needs its own summary. Only intent_id inherits from the top level. Returned ids match item order; retry only failed indices.",
|
||||
}
|
||||
schema := obj(props)
|
||||
// Providers reject root-level anyOf. The handler enforces single/batch mode.
|
||||
schema := obj(map[string]any{
|
||||
"facts": map[string]any{
|
||||
"type": "array", "minItems": 1, "items": factItemSchema(),
|
||||
"description": recordFactFactsDescription,
|
||||
},
|
||||
}, "facts")
|
||||
schema["additionalProperties"] = false
|
||||
return schema
|
||||
}
|
||||
|
||||
// RepairRecordFactSchema restores the single/batch input contract in stored or
|
||||
// cached schemas, preserving annotations only on fields the handler accepts.
|
||||
// RepairRecordFactSchema brings a stored or cached record_fact schema to the
|
||||
// facts-only contract. The structure always comes from the code; of the stored
|
||||
// schema only the annotations (description, default) of facts and of its known
|
||||
// item fields survive. Top-level fact fields of the earlier contract are
|
||||
// dropped: the handler still accepts them, but the model must not see them.
|
||||
func RepairRecordFactSchema(stored map[string]any) map[string]any {
|
||||
raw, _ := json.Marshal(stored)
|
||||
var out map[string]any
|
||||
_ = json.Unmarshal(raw, &out)
|
||||
if out == nil {
|
||||
out = map[string]any{}
|
||||
out := recordFactSchema()
|
||||
facts := out["properties"].(map[string]any)["facts"].(map[string]any)
|
||||
storedProps, _ := stored["properties"].(map[string]any)
|
||||
storedFacts, _ := storedProps["facts"].(map[string]any)
|
||||
if storedFacts == nil {
|
||||
return out
|
||||
}
|
||||
mergeFactContract(out, recordFactSchema())
|
||||
// A batch requires summaries on its items, never a redundant top-level one.
|
||||
delete(out, "required")
|
||||
delete(out, "anyOf")
|
||||
canonical := recordFactSchema()["properties"].(map[string]any)
|
||||
props := out["properties"].(map[string]any)
|
||||
for name := range props {
|
||||
if _, known := canonical[name]; !known {
|
||||
delete(props, name)
|
||||
if d, ok := storedFacts["description"].(string); ok && strings.TrimSpace(d) != "" {
|
||||
facts["description"] = d
|
||||
}
|
||||
storedItems, _ := storedFacts["items"].(map[string]any)
|
||||
storedItemProps, _ := storedItems["properties"].(map[string]any)
|
||||
itemProps := facts["items"].(map[string]any)["properties"].(map[string]any)
|
||||
for name, p := range itemProps {
|
||||
sp, _ := storedItemProps[name].(map[string]any)
|
||||
if sp == nil {
|
||||
continue
|
||||
}
|
||||
}
|
||||
items := props["facts"].(map[string]any)["items"].(map[string]any)
|
||||
itemProps := items["properties"].(map[string]any)
|
||||
for name := range itemProps {
|
||||
if _, known := canonical[name]; !known || name == "facts" {
|
||||
delete(itemProps, name)
|
||||
prop := p.(map[string]any)
|
||||
for _, key := range []string{"description", "default"} {
|
||||
if v, ok := sp[key]; ok && v != nil {
|
||||
prop[key] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func mergeFactContract(dst, src map[string]any) {
|
||||
for key, value := range src {
|
||||
if key == "description" || key == "default" {
|
||||
if _, ok := dst[key]; ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if child, ok := value.(map[string]any); ok {
|
||||
target, _ := dst[key].(map[string]any)
|
||||
if target == nil {
|
||||
target = map[string]any{}
|
||||
dst[key] = target
|
||||
}
|
||||
mergeFactContract(target, child)
|
||||
} else {
|
||||
dst[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type recordFactInput struct {
|
||||
Facts []factItem `json:"facts"`
|
||||
factItem
|
||||
@@ -103,6 +107,9 @@ type recordFactInput struct {
|
||||
|
||||
// Validate exact field names before decoding: encoding/json otherwise treats
|
||||
// Summary, SUMMARY, etc. as aliases even with DisallowUnknownFields enabled.
|
||||
// Three input shapes reach the handler: the published one ({facts:[...]}), the
|
||||
// legacy single fact (fields at the top level, no facts) and the legacy batch
|
||||
// with a top-level intent_id as the default of its items.
|
||||
func decodeRecordFactInput(in json.RawMessage) (recordFactInput, bool, error) {
|
||||
var out recordFactInput
|
||||
fields, err := exactFactFields(in, true)
|
||||
@@ -111,11 +118,6 @@ func decodeRecordFactInput(in json.RawMessage) (recordFactInput, bool, error) {
|
||||
}
|
||||
_, batch := fields["facts"]
|
||||
if batch {
|
||||
for name := range fields {
|
||||
if name != "intent_id" && name != "facts" {
|
||||
return out, true, fmt.Errorf("field %q is not allowed at the top level in batch mode; only intent_id and facts are accepted", name)
|
||||
}
|
||||
}
|
||||
var items []json.RawMessage
|
||||
if err := json.Unmarshal(fields["facts"], &items); err != nil {
|
||||
return out, true, fmt.Errorf("facts must be an array: %w", err)
|
||||
@@ -123,10 +125,16 @@ func decodeRecordFactInput(in json.RawMessage) (recordFactInput, bool, error) {
|
||||
if len(items) == 0 {
|
||||
return out, true, fmt.Errorf("facts must be a non-empty array of complete facts, each with its own summary")
|
||||
}
|
||||
itemFields := make([]map[string]json.RawMessage, len(items))
|
||||
for i, item := range items {
|
||||
if _, err := exactFactFields(item, false); err != nil {
|
||||
f, err := exactFactFields(item, false)
|
||||
if err != nil {
|
||||
return out, true, fmt.Errorf("facts[%d]: %w", i, err)
|
||||
}
|
||||
itemFields[i] = f
|
||||
}
|
||||
if err := checkBatchTopLevel(fields, itemFields); err != nil {
|
||||
return out, true, err
|
||||
}
|
||||
}
|
||||
decoder := json.NewDecoder(bytes.NewReader(in))
|
||||
@@ -137,6 +145,28 @@ func decodeRecordFactInput(in json.RawMessage) (recordFactInput, bool, error) {
|
||||
return out, batch, nil
|
||||
}
|
||||
|
||||
// checkBatchTopLevel enforces the contract at the top level of a facts[] call,
|
||||
// where only facts and (legacy) intent_id carry meaning. Any other top-level
|
||||
// field is refused by name before anything is written, including empty
|
||||
// placeholders and copies of a fact's fields: a value there is at best
|
||||
// redundant and at worst a second, conflicting claim. The message names the
|
||||
// one accepted shape, so a model that filled every declared property of an
|
||||
// older schema learns where the fields belong.
|
||||
func checkBatchTopLevel(fields map[string]json.RawMessage, items []map[string]json.RawMessage) error {
|
||||
var extra []string
|
||||
for name := range fields {
|
||||
if name == "intent_id" || name == "facts" {
|
||||
continue
|
||||
}
|
||||
extra = append(extra, fmt.Sprintf("%q", name))
|
||||
}
|
||||
if len(extra) == 0 {
|
||||
return nil
|
||||
}
|
||||
sort.Strings(extra)
|
||||
return fmt.Errorf("top-level field(s) %s are not allowed beside facts (%d item(s)): record_fact takes only {\"facts\":[...]}; put every field of a fact inside its facts item and send nothing else at the top level", strings.Join(extra, ", "), len(items))
|
||||
}
|
||||
|
||||
func exactFactFields(in json.RawMessage, topLevel bool) (map[string]json.RawMessage, error) {
|
||||
var fields map[string]json.RawMessage
|
||||
if err := json.Unmarshal(in, &fields); err != nil {
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package agent
|
||||
|
||||
// Texts of the earlier record_fact contract (fact fields at the top level
|
||||
// beside facts[]), kept verbatim so the server's one-time refresh
|
||||
// (server/fact_input_schema.go) can tell a stored default from an operator
|
||||
// edit. Nothing here is published to a model.
|
||||
|
||||
// recordFactLegacyDescription is the record_fact description seeded up to the
|
||||
// facts-only contract.
|
||||
const recordFactLegacyDescription = "Write an exploration [fact/conclusion] into the exploration graph, linked to the intent that produced it (intent_id). Used to record exploration results — both [positive conclusions] like fingerprinting/enumeration, and [negative conclusions] like 'port closed'/'parameter not injectable'/'no login entry found'.\n" +
|
||||
"⚠️Multiple observations from one exploration must be [consolidated into ONE fact], not split into many; whenever they can be merged into one fact, use one: summary = a one-sentence summary of this conclusion, detail = the related details (may contain multiple concrete items). Example: a fingerprinting intent → one fact {summary:'identified the tech stack and response characteristics of site X', detail:'nginx 1.25 / Vue3 / 200 / title=.. / body_len=..'}, rather than one fact each for status code, fingerprint, and title. One intent usually produces exactly one fact; splitting too finely bloats the graph endlessly.\n" +
|
||||
"★The facts array writes several [mutually distinct] conclusions at once (each may omit intent_id, defaulting to the top-level intent_id). Returns an ids array, same length and order as facts.\n" +
|
||||
"⚠️Write only conclusions you [actually saw] in tool output — don't extrapolate. evidence and confidence keep inaccurate conclusions from polluting the graph:\n" +
|
||||
" · evidence = [one line] of key evidence supporting this conclusion (the command + the one or two most proving output lines), **keep it brief** — details belong in detail; don't paste large output blocks here.\n" +
|
||||
" · confidence = observed (seen directly in output) | inferred (inferred from phenomena).\n" +
|
||||
" · source = where the content came from: target_response (content the target itself returned: page bodies, headers, error messages, banners, even when a tool fetched it) | tool_output (a tool's own result about the target: port states, scanner verdicts, status codes, timings) | third_party_intel (OSINT, CVE databases, public reports) | operator_input (given by the human operator) | inference (your own reasoning; the default when omitted). Any other value is refused.\n" +
|
||||
" · **Negative conclusions** (not injectable / port closed / no entry found, etc.) state only \"observation + tentative reading\" — state what you actually saw; whether to abandon the direction is for the planner to decide globally; always provide evidence, mark inferred when the means weren't exhausted or the evidence is weak (including probed only once, looks-like), and mark observed only when truly exhausted and directly seen."
|
||||
|
||||
// recordFactReleasedDescription is the record_fact description seeded by the
|
||||
// releases v0.4.0 to v0.6.0 (agent/tools.go at those tags): the text above
|
||||
// without the source bullet.
|
||||
const recordFactReleasedDescription = "Write an exploration [fact/conclusion] into the exploration graph, linked to the intent that produced it (intent_id). Used to record exploration results — both [positive conclusions] like fingerprinting/enumeration, and [negative conclusions] like 'port closed'/'parameter not injectable'/'no login entry found'.\n" +
|
||||
"⚠️Multiple observations from one exploration must be [consolidated into ONE fact], not split into many; whenever they can be merged into one fact, use one: summary = a one-sentence summary of this conclusion, detail = the related details (may contain multiple concrete items). Example: a fingerprinting intent → one fact {summary:'identified the tech stack and response characteristics of site X', detail:'nginx 1.25 / Vue3 / 200 / title=.. / body_len=..'}, rather than one fact each for status code, fingerprint, and title. One intent usually produces exactly one fact; splitting too finely bloats the graph endlessly.\n" +
|
||||
"★The facts array writes several [mutually distinct] conclusions at once (each may omit intent_id, defaulting to the top-level intent_id). Returns an ids array, same length and order as facts.\n" +
|
||||
"⚠️Write only conclusions you [actually saw] in tool output — don't extrapolate. evidence and confidence keep inaccurate conclusions from polluting the graph:\n" +
|
||||
" · evidence = [one line] of key evidence supporting this conclusion (the command + the one or two most proving output lines), **keep it brief** — details belong in detail; don't paste large output blocks here.\n" +
|
||||
" · confidence = observed (seen directly in output) | inferred (inferred from phenomena).\n" +
|
||||
" · **Negative conclusions** (not injectable / port closed / no entry found, etc.) state only \"observation + tentative reading\" — state what you actually saw; whether to abandon the direction is for the planner to decide globally; always provide evidence, mark inferred when the means weren't exhausted or the evidence is weak (including probed only once, looks-like), and mark observed only when truly exhausted and directly seen."
|
||||
|
||||
// recordFactLegacyItemDescriptions are the facts[] item descriptions of the
|
||||
// earlier contract whose wording referred to the top level; the refresh
|
||||
// replaces exactly these texts with the current ones.
|
||||
var recordFactLegacyItemDescriptions = map[string]string{
|
||||
"summary": "Required on every fact: a non-empty one-sentence summary of this conclusion. Batch items do not inherit summary from the top level.",
|
||||
"intent_id": "The intent that produced this fact; only this field inherits from the top level in a batch.",
|
||||
}
|
||||
|
||||
// recordFactLegacyFactsDescription is the facts property description of the
|
||||
// earlier contract.
|
||||
const recordFactLegacyFactsDescription = "A non-empty batch of complete facts. Every item needs its own summary. Only intent_id inherits from the top level. Returned ids match item order; retry only failed indices."
|
||||
|
||||
// recordFactReleasedFactsDescription is the facts property description seeded
|
||||
// by the releases v0.4.0 to v0.6.0. RepairRecordFactSchema keeps a stored facts
|
||||
// description, so the refresh has to know this text to replace it.
|
||||
const recordFactReleasedFactsDescription = "[use when there are several distinct conclusions] array of facts; element fields same as the top-level fields below (summary/detail/evidence/confidence/intent_id/asset_ids); omitting intent_id falls back to the top-level intent_id. The returned ids match this array in length and order."
|
||||
|
||||
// RecordFactLegacyDescriptions returns the description texts of the earlier
|
||||
// contract that the refresh may replace: the tool descriptions, the facts
|
||||
// property descriptions and the item descriptions.
|
||||
func RecordFactLegacyDescriptions() (tool, facts []string, items map[string]string) {
|
||||
return []string{recordFactLegacyDescription, recordFactReleasedDescription},
|
||||
[]string{recordFactLegacyFactsDescription, recordFactReleasedFactsDescription},
|
||||
recordFactLegacyItemDescriptions
|
||||
}
|
||||
+244
-16
@@ -3,9 +3,11 @@ package agent
|
||||
import (
|
||||
"encoding/json"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
actool "github.com/Autumn-27/norma/tool"
|
||||
)
|
||||
|
||||
@@ -47,6 +49,10 @@ func TestRecordFactSummaryContract(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A stored schema of the earlier contract (fact fields at the top level beside
|
||||
// facts[], operator annotations, a stray property) is republished as the
|
||||
// facts-only contract; annotations of facts and of its items survive, the top
|
||||
// level loses every fact field, and the result is idempotent.
|
||||
func TestRecordFactStoredContractRepair(t *testing.T) {
|
||||
old := map[string]any{
|
||||
"type": "object", "required": []any{"summary"},
|
||||
@@ -55,32 +61,40 @@ func TestRecordFactStoredContractRepair(t *testing.T) {
|
||||
"summary": map[string]any{"type": "string", "description": "operator summary"},
|
||||
"confidence": map[string]any{"type": "string", "default": "inferred"},
|
||||
"custom_field": map[string]any{"type": "string"},
|
||||
"facts": map[string]any{"type": "array", "items": map[string]any{"type": "object"}},
|
||||
"facts": map[string]any{"type": "array", "description": "operator facts", "items": map[string]any{"type": "object", "properties": map[string]any{
|
||||
"summary": map[string]any{"type": "string", "description": "operator item summary"},
|
||||
"confidence": map[string]any{"type": "string", "default": "observed"},
|
||||
"custom": map[string]any{"type": "string"},
|
||||
}}},
|
||||
},
|
||||
}
|
||||
base := NewToolSet(nil, "").recordFact()
|
||||
repaired := DecorateTool(base, "operator tool", old)
|
||||
schema := repaired.InputSchema()
|
||||
if _, required := schema["required"]; required {
|
||||
t.Fatal("batch still requires a top-level summary")
|
||||
if req, _ := schema["required"].([]string); len(req) != 1 || req[0] != "facts" {
|
||||
t.Fatalf("facts must be the only required property: %v", schema["required"])
|
||||
}
|
||||
if _, exists := schema["anyOf"]; exists {
|
||||
t.Fatal("root anyOf reaches the provider")
|
||||
}
|
||||
props := schema["properties"].(map[string]any)
|
||||
item := props["facts"].(map[string]any)["items"].(map[string]any)
|
||||
if len(props) != 1 || props["facts"] == nil || schema["additionalProperties"] != false {
|
||||
t.Fatalf("top level must hold facts only: %v", props)
|
||||
}
|
||||
facts := props["facts"].(map[string]any)
|
||||
item := facts["items"].(map[string]any)
|
||||
required := item["required"].([]string)
|
||||
if len(required) != 1 || required[0] != "summary" || props["facts"].(map[string]any)["minItems"] != 1 {
|
||||
if len(required) != 1 || required[0] != "summary" || facts["minItems"] != 1 {
|
||||
t.Fatal("batch must require a nonempty list with a summary per item")
|
||||
}
|
||||
if props["summary"].(map[string]any)["minLength"] != 1 ||
|
||||
item["properties"].(map[string]any)["summary"].(map[string]any)["minLength"] != 1 {
|
||||
itemProps := item["properties"].(map[string]any)
|
||||
if itemProps["summary"].(map[string]any)["minLength"] != 1 {
|
||||
t.Fatal("empty summaries permitted by schema")
|
||||
}
|
||||
if repaired.Description() != "operator tool" ||
|
||||
props["summary"].(map[string]any)["description"] != "operator summary" ||
|
||||
props["confidence"].(map[string]any)["default"] != "inferred" || props["custom_field"] != nil {
|
||||
t.Fatal("operator annotations lost")
|
||||
if repaired.Description() != "operator tool" || facts["description"] != "operator facts" ||
|
||||
itemProps["summary"].(map[string]any)["description"] != "operator item summary" ||
|
||||
itemProps["confidence"].(map[string]any)["default"] != "observed" || itemProps["custom"] != nil {
|
||||
t.Fatalf("item annotations lost or stray property kept: %v", itemProps)
|
||||
}
|
||||
if _, ok := old["properties"].(map[string]any)["tested_asset_ids"]; ok {
|
||||
t.Fatal("shared old schema mutated")
|
||||
@@ -94,9 +108,18 @@ func TestRecordFactStoredContractRepair(t *testing.T) {
|
||||
if err := json.Unmarshal(first, &roundTrip); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, input := range []string{`{"summary":"single"}`, `{"facts":[{"summary":"batch"}]}`} {
|
||||
if err := actool.ValidateInput(roundTrip, json.RawMessage(input)); err != nil {
|
||||
t.Fatalf("SDK rejects valid %s after catalog round trip: %v", input, err)
|
||||
if err := actool.ValidateInput(roundTrip, json.RawMessage(`{"facts":[{"summary":"batch"}]}`)); err != nil {
|
||||
t.Fatalf("SDK rejects the published shape after catalog round trip: %v", err)
|
||||
}
|
||||
// The legacy single shape no longer passes the published schema; the
|
||||
// handler validates its own input instead, also behind the catalog wrapper.
|
||||
if err := actool.ValidateInput(roundTrip, json.RawMessage(`{"summary":"single"}`)); err == nil {
|
||||
t.Fatal("published schema must require facts")
|
||||
}
|
||||
for _, tool := range []actool.CoreTool{base, repaired} {
|
||||
r, ok := tool.(interface{ AcceptsRawInput() bool })
|
||||
if !ok || !r.AcceptsRawInput() {
|
||||
t.Fatalf("%T must opt out of the harness schema check", tool)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,7 +163,7 @@ func TestRecordFactStrictFields(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRecordFactSchemaMatchesStrings(t *testing.T) {
|
||||
props := recordFactSchema()["properties"].(map[string]any)
|
||||
props := factItemSchema()["properties"].(map[string]any)
|
||||
summary := regexp.MustCompile(props["summary"].(map[string]any)["pattern"].(string))
|
||||
for _, value := range []string{"", " ", "\t\r\n", "\u00a0\u0085", "\u2003\u3000", "conclusion", " observed "} {
|
||||
if got, want := summary.MatchString(value), strings.TrimSpace(value) != ""; got != want {
|
||||
@@ -155,7 +178,7 @@ func TestRecordFactSchemaMatchesStrings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
for _, input := range []string{
|
||||
`{"summary":"single","asset_ids":["1",2]}`,
|
||||
`{"facts":[{"summary":"batch","asset_ids":["1",2]}]}`,
|
||||
`{"facts":[{"summary":"batch","tested_asset_ids":["1",2]}]}`,
|
||||
} {
|
||||
if err := actool.ValidateInput(recordFactSchema(), json.RawMessage(input)); err != nil {
|
||||
@@ -163,3 +186,208 @@ func TestRecordFactSchemaMatchesStrings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A model that fills every declared property of the earlier schema sends the
|
||||
// single fact inside facts[] and a copy (or a placeholder) of every fact field
|
||||
// beside it. Such a call is refused by name before any write, whether the
|
||||
// copies are identical, empty or dummies, and the message names the one shape
|
||||
// that is accepted. The published schema no longer declares those fields.
|
||||
func TestRecordFactRefusesTopLevelCopiesBesideFacts(t *testing.T) {
|
||||
store := guardTaskStore(t)
|
||||
intentID := addGuardNode(t, store, db.KindIntent, map[string]any{"summary": "fingerprint the service"}, "running")
|
||||
tools := NewToolSet(store, "worker")
|
||||
before, err := store.ListByKind(db.KindFact, 100)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id := strconv.FormatInt(intentID, 10)
|
||||
fact := `{"summary":"TLS 1.0 is offered on port 8443","detail":"the handshake succeeded with TLSv1.0","evidence":"openssl s_client -tls1 → Protocol: TLSv1","confidence":"observed","source":"tool_output","intent_id":` + id + `,"asset_ids":[]}`
|
||||
for _, tc := range []struct{ call, want string }{
|
||||
// an exact copy of every field beside facts[]
|
||||
{`{"summary":"TLS 1.0 is offered on port 8443","detail":"the handshake succeeded with TLSv1.0","evidence":"openssl s_client -tls1 → Protocol: TLSv1","confidence":"observed","source":"tool_output","intent_id":` + id + `,"asset_ids":[],"facts":[` + fact + `]}`, `"asset_ids", "confidence", "detail", "evidence", "source", "summary"`},
|
||||
// empty placeholders only
|
||||
{`{"summary":"","detail":"","evidence":"","confidence":"","source":"","asset_ids":[],"tested_asset_ids":[],"intent_id":` + id + `,"facts":[` + fact + `]}`, `"asset_ids", "confidence", "detail", "evidence", "source", "summary", "tested_asset_ids"`},
|
||||
// dummy values
|
||||
{`{"summary":"x","facts":[` + fact + `]}`, `"summary"`},
|
||||
{`{"summary":null,"facts":[` + fact + `]}`, `"summary"`},
|
||||
} {
|
||||
w := tools.Writes().Facts
|
||||
r := callGuardTool(t, tools.recordFact(), tc.call)
|
||||
if !r.IsError || !strings.Contains(r.Flatten(), tc.want) || !strings.Contains(r.Flatten(), `record_fact takes only {"facts":[...]}`) || tools.Writes().Facts != w {
|
||||
t.Errorf("%s: want refusal naming %s, got %s (writes %d→%d)", tc.call, tc.want, r.Flatten(), w, tools.Writes().Facts)
|
||||
}
|
||||
}
|
||||
if n, err := store.ListByKind(db.KindFact, 100); err != nil || len(n) != len(before) {
|
||||
t.Fatalf("refused calls wrote facts: %d → %d %v", len(before), len(n), err)
|
||||
}
|
||||
// The same fact in the published shape is written once and linked.
|
||||
res := callGuardTool(t, tools.recordFact(), `{"facts":[`+fact+`]}`)
|
||||
if res.IsError || tools.Writes().Facts != 1 {
|
||||
t.Fatalf("published shape refused: %s", res.Flatten())
|
||||
}
|
||||
var out struct {
|
||||
IDs []int64 `json:"ids"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(res.Flatten()), &out); err != nil || len(out.IDs) != 1 || out.IDs[0] <= 0 {
|
||||
t.Fatalf("batch result must carry exactly one id: %s", res.Flatten())
|
||||
}
|
||||
if yielded, err := store.FactsYielded(intentID); err != nil || len(yielded) != 1 || yielded[0] != out.IDs[0] {
|
||||
t.Fatalf("fact not linked to the intent: %v %v", yielded, err)
|
||||
}
|
||||
node, err := store.GetNode(out.IDs[0])
|
||||
if err != nil || node == nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var payload map[string]any
|
||||
_ = json.Unmarshal(node.Payload, &payload)
|
||||
if payload["summary"] != "TLS 1.0 is offered on port 8443" || payload["source"] != "tool_output" || payload["confidence"] != "observed" {
|
||||
t.Fatalf("fact payload: %s", node.Payload)
|
||||
}
|
||||
}
|
||||
|
||||
// Conflicting copies, placeholders, unknown fields, bad asset ids, missing
|
||||
// summaries and empty batches are refused, and nothing is written by a
|
||||
// refused call.
|
||||
func TestRecordFactBatchTopLevelConflicts(t *testing.T) {
|
||||
store := guardTaskStore(t)
|
||||
tools := NewToolSet(store, "worker")
|
||||
before, err := store.ListByKind(db.KindFact, 100) // the task's origin fact
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, tc := range []struct{ call, want string }{
|
||||
// dummy summaries a model may send after a refusal
|
||||
{`{"summary":"x","facts":[{"summary":"real conclusion"}]}`, `"summary"`},
|
||||
{`{"summary":"placeholder","detail":"test","evidence":"test","facts":[{"summary":"real","detail":"real detail","evidence":"real evidence"}]}`, `"detail", "evidence", "summary"`},
|
||||
{`{"summary":"contradictory","facts":[{"summary":"different"}]}`, `"summary"`},
|
||||
{`{"detail":"invented","facts":[{"summary":"legitimate"}]}`, `"detail"`},
|
||||
{`{"confidence":"observed","facts":[{"summary":"fact says inferred","confidence":"inferred"}]}`, `"confidence"`},
|
||||
{`{"source":"inference","facts":[{"summary":"fact says tool_output","source":"tool_output"}]}`, `"source"`},
|
||||
{`{"asset_ids":[1],"facts":[{"summary":"fact has other assets","asset_ids":[2]}]}`, `"asset_ids"`},
|
||||
{`{"summary":"first","facts":[{"summary":"first"},{"summary":"second"}]}`, `(2 item(s))`},
|
||||
{`{"summary":"x","typo":1,"facts":[{"summary":"unknown field"}]}`, `"typo"`},
|
||||
{`{"facts":[{"summary":"unknown nested","typo":1}]}`, `"typo"`},
|
||||
{`{"facts":[{"summary":"bad asset id","asset_ids":["abc"]}]}`, `asset`},
|
||||
{`{"summary":"must not inherit","facts":[{"detail":"missing summary"}]}`, `"summary"`},
|
||||
{`{"summary":"x","facts":[]}`, `non-empty`},
|
||||
{`{"facts":[]}`, `non-empty`},
|
||||
{`{"summary":"","facts":[]}`, `non-empty`},
|
||||
} {
|
||||
w := tools.Writes().Facts
|
||||
r := callGuardTool(t, tools.recordFact(), tc.call)
|
||||
if !r.IsError || !strings.Contains(r.Flatten(), tc.want) || tools.Writes().Facts != w {
|
||||
t.Errorf("%s: want refusal mentioning %s, got %s (writes %d→%d)", tc.call, tc.want, r.Flatten(), w, tools.Writes().Facts)
|
||||
}
|
||||
}
|
||||
if n, err := store.ListByKind(db.KindFact, 100); err != nil || len(n) != len(before) {
|
||||
t.Fatalf("refused calls wrote facts: %d → %d %v", len(before), len(n), err)
|
||||
}
|
||||
}
|
||||
|
||||
// The published schema holds facts[] and nothing else, and the description
|
||||
// names that one shape; the earlier "two shapes" wording is gone.
|
||||
func TestRecordFactSchemaIsFactsOnly(t *testing.T) {
|
||||
schema := recordFactSchema()
|
||||
props := schema["properties"].(map[string]any)
|
||||
if len(props) != 1 || props["facts"] == nil {
|
||||
t.Fatalf("top-level properties: %v", props)
|
||||
}
|
||||
if req, _ := schema["required"].([]string); len(req) != 1 || req[0] != "facts" || schema["additionalProperties"] != false {
|
||||
t.Fatalf("facts must be required and the only property: %v %v", schema["required"], schema["additionalProperties"])
|
||||
}
|
||||
facts := props["facts"].(map[string]any)
|
||||
if d, _ := facts["description"].(string); !strings.Contains(d, "never send summary") {
|
||||
t.Errorf("facts description must forbid top-level copies: %q", d)
|
||||
}
|
||||
item := facts["items"].(map[string]any)["properties"].(map[string]any)
|
||||
for _, name := range []string{"summary", "intent_id", "detail", "evidence", "confidence", "source", "asset_ids", "tested_asset_ids"} {
|
||||
if item[name] == nil {
|
||||
t.Errorf("facts[] item lacks %s", name)
|
||||
}
|
||||
}
|
||||
for name, d := range map[string]string{
|
||||
"summary": item["summary"].(map[string]any)["description"].(string),
|
||||
"intent_id": item["intent_id"].(map[string]any)["description"].(string),
|
||||
} {
|
||||
if strings.Contains(d, "top level") || strings.Contains(d, "top-level") {
|
||||
t.Errorf("facts[].%s still refers to a top level: %q", name, d)
|
||||
}
|
||||
}
|
||||
desc := NewToolSet(nil, "").recordFact().Description()
|
||||
if !strings.HasSuffix(desc, recordFactContractNote) || strings.Contains(desc, "top-level intent_id") {
|
||||
t.Fatalf("record_fact description must describe the facts-only contract: %q", desc)
|
||||
}
|
||||
// The seed the catalog stores is the same contract.
|
||||
for _, seed := range BuiltinToolSeeds() {
|
||||
if seed.Key != "record_fact" {
|
||||
continue
|
||||
}
|
||||
if seed.Desc != desc {
|
||||
t.Fatal("seed description differs from the tool")
|
||||
}
|
||||
if p := seed.Schema["properties"].(map[string]any); len(p) != 1 || p["facts"] == nil {
|
||||
t.Fatalf("seed schema is not facts-only: %v", p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A facts[] item without intent_id is linked to the intent the worker runs
|
||||
// (SetOwnerNode); a legacy top-level intent_id still wins; a planner ToolSet
|
||||
// (owner = the task root, not an intent) writes an unlinked fact.
|
||||
func TestRecordFactDefaultsToRunningIntent(t *testing.T) {
|
||||
store := guardTaskStore(t)
|
||||
running := addGuardNode(t, store, db.KindIntent, map[string]any{"summary": "running intent"}, "running")
|
||||
other := addGuardNode(t, store, db.KindIntent, map[string]any{"summary": "other intent"}, "open")
|
||||
tools := NewToolSet(store, "worker")
|
||||
tools.SetOwnerNode(running)
|
||||
ids := func(res actool.Result) []int64 {
|
||||
t.Helper()
|
||||
var out struct {
|
||||
IDs []int64 `json:"ids"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(res.Flatten()), &out); err != nil || len(out.IDs) != 1 || out.IDs[0] <= 0 {
|
||||
t.Fatalf("batch result: %s", res.Flatten())
|
||||
}
|
||||
return out.IDs
|
||||
}
|
||||
res := callGuardTool(t, tools.recordFact(), `{"facts":[{"summary":"linked to the running intent","confidence":"observed","source":"tool_output"}]}`)
|
||||
if res.IsError {
|
||||
t.Fatal(res.Flatten())
|
||||
}
|
||||
first := ids(res)[0]
|
||||
if yielded, err := store.FactsYielded(running); err != nil || len(yielded) != 1 || yielded[0] != first {
|
||||
t.Fatalf("fact %d not linked to the running intent %d: %v %v", first, running, yielded, err)
|
||||
}
|
||||
res = callGuardTool(t, tools.recordFact(), `{"intent_id":`+strconv.FormatInt(other, 10)+`,"facts":[{"summary":"legacy top-level intent"}]}`)
|
||||
if res.IsError {
|
||||
t.Fatal(res.Flatten())
|
||||
}
|
||||
second := ids(res)[0]
|
||||
if yielded, err := store.FactsYielded(other); err != nil || len(yielded) != 1 || yielded[0] != second {
|
||||
t.Fatalf("legacy top-level intent_id must win: %v %v", yielded, err)
|
||||
}
|
||||
res = callGuardTool(t, tools.recordFact(), `{"facts":[{"summary":"item intent","intent_id":`+strconv.FormatInt(other, 10)+`}]}`)
|
||||
if res.IsError {
|
||||
t.Fatal(res.Flatten())
|
||||
}
|
||||
third := ids(res)[0]
|
||||
if yielded, _ := store.FactsYielded(other); len(yielded) != 2 || yielded[1] != third && yielded[0] != third {
|
||||
t.Fatalf("item intent_id must win: %v", yielded)
|
||||
}
|
||||
if yielded, _ := store.FactsYielded(running); len(yielded) != 1 {
|
||||
t.Fatalf("running intent gained facts it did not produce: %v", yielded)
|
||||
}
|
||||
planner := NewToolSet(store, "planner")
|
||||
origin, err := store.ListByKind(db.KindFact, 1)
|
||||
if err != nil || len(origin) == 0 {
|
||||
t.Fatalf("origin fact: %v", err)
|
||||
}
|
||||
planner.SetOwnerNode(origin[0].ID)
|
||||
res = callGuardTool(t, planner.recordFact(), `{"facts":[{"summary":"planner fact without intent"}]}`)
|
||||
if res.IsError || planner.Writes().Facts != 1 {
|
||||
t.Fatalf("planner write refused: %s", res.Flatten())
|
||||
}
|
||||
if yielded, _ := store.FactsYielded(running); len(yielded) != 1 {
|
||||
t.Fatalf("planner fact must not be linked to a worker intent: %v", yielded)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,10 @@ func TestReportFindingStoresReasoningFields(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteTask(task.ID)
|
||||
defer func() {
|
||||
_, _ = d.DeleteFindingsByTask(task.ID)
|
||||
_ = d.DeleteTask(task.ID)
|
||||
}()
|
||||
ts := NewToolSet(nil, "")
|
||||
ts.ts, ts.taskID = d.Exploration(task.ExplorationID), task.ID
|
||||
for _, tc := range []struct{ extra, counter, rationale string }{
|
||||
|
||||
@@ -25,7 +25,10 @@ func TestReportFindingOptionalTrafficWithoutCapture(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteTask(task.ID)
|
||||
defer func() {
|
||||
_, _ = d.DeleteFindingsByTask(task.ID)
|
||||
_ = d.DeleteTask(task.ID)
|
||||
}()
|
||||
ts := NewToolSet(nil, "")
|
||||
ts.ts, ts.taskID = d.Exploration(task.ExplorationID), task.ID
|
||||
ts.SetFindingRecorder(evidence.New(d, nil, t.TempDir()))
|
||||
@@ -60,7 +63,10 @@ func TestReportFindingAtomicContract(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteTask(task.ID)
|
||||
defer func() {
|
||||
_, _ = d.DeleteFindingsByTask(task.ID)
|
||||
_ = d.DeleteTask(task.ID)
|
||||
}()
|
||||
ts := NewToolSet(nil, "")
|
||||
ts.ts = d.Exploration(task.ExplorationID)
|
||||
ts.taskID = task.ID
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
)
|
||||
|
||||
// Synthetic replay of the record_fact call shapes a model produces, replayed
|
||||
// against the handler in the package test database. The shapes mirror what
|
||||
// was observed in production before the facts-only contract (a model filling
|
||||
// every declared top-level property beside facts[]) without using recorded
|
||||
// data. Checked per call: the verdict, that an accepted call writes exactly one
|
||||
// node per facts item linked to the intent and anchored to the assets, and
|
||||
// that a refused call writes nothing and names the top-level fields.
|
||||
func TestRecordFactShapesReplay(t *testing.T) {
|
||||
d := testDB(t)
|
||||
t.Cleanup(func() { _ = d.Close() })
|
||||
task, err := d.CreateTaskWithOptions("record_fact shapes", "replay synthetic record_fact call shapes", db.TaskCreateOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = d.DeleteTask(task.ID) })
|
||||
store := d.Exploration(task.ExplorationID)
|
||||
intentID := addGuardNode(t, store, db.KindIntent, map[string]any{"summary": "enumerate the service"}, "running")
|
||||
var assets []int64
|
||||
for i := 1; i <= 2; i++ {
|
||||
id, err := d.Assets().UpsertIP(db.UpsertIPReq{IP: fmt.Sprintf("203.0.113.%d", i), TaskID: task.ID})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assets = append(assets, id)
|
||||
}
|
||||
t.Cleanup(func() { _, _ = d.Assets().DeleteByIDs(assets) })
|
||||
tools := NewToolSet(store, "worker")
|
||||
tools.SetOwnerNode(intentID)
|
||||
tool := tools.recordFact()
|
||||
|
||||
iid := strconv.FormatInt(intentID, 10)
|
||||
a1, a2 := strconv.FormatInt(assets[0], 10), strconv.FormatInt(assets[1], 10)
|
||||
item := func(n int) string {
|
||||
return fmt.Sprintf(`{"summary":"conclusion %d","detail":"detail %d","evidence":"cmd %d → line","confidence":"observed","source":"tool_output","asset_ids":[%s]}`, n, n, n, a1)
|
||||
}
|
||||
type shape struct {
|
||||
name string
|
||||
call string
|
||||
accept bool
|
||||
items int
|
||||
fields string // named in the refusal
|
||||
}
|
||||
shapes := []shape{
|
||||
{"published: one item", `{"facts":[` + item(1) + `]}`, true, 1, ""},
|
||||
{"published: two items", `{"facts":[` + item(1) + `,` + item(2) + `]}`, true, 2, ""},
|
||||
{"published: item with its own intent_id and alias", `{"facts":[{"summary":"alias","tested_asset_ids":["` + a2 + `"],"intent_id":` + iid + `}]}`, true, 1, ""},
|
||||
{"legacy batch: top-level intent_id", `{"intent_id":` + iid + `,"facts":[` + item(3) + `]}`, true, 1, ""},
|
||||
{"legacy single", `{"summary":"single fact","confidence":"inferred","asset_ids":[` + a2 + `]}`, true, 1, ""},
|
||||
{"copies of every field beside facts", `{"summary":"conclusion 1","detail":"detail 1","evidence":"cmd 1 → line","confidence":"observed","source":"tool_output","asset_ids":[` + a1 + `],"facts":[` + item(1) + `]}`, false, 1, `"asset_ids", "confidence", "detail", "evidence", "source", "summary"`},
|
||||
{"empty placeholders beside facts", `{"summary":"","detail":"","asset_ids":[],"tested_asset_ids":[],"facts":[` + item(1) + `]}`, false, 1, `"asset_ids", "detail", "summary", "tested_asset_ids"`},
|
||||
{"dummy summary beside facts", `{"summary":"x","facts":[` + item(1) + `]}`, false, 1, `"summary"`},
|
||||
{"abbreviated copy beside facts", `{"summary":"short","detail":"short detail","facts":[` + item(1) + `]}`, false, 1, `"detail", "summary"`},
|
||||
{"conflicting source beside facts", `{"source":"inference","facts":[` + item(1) + `]}`, false, 1, `"source"`},
|
||||
{"top-level summary beside two items", `{"summary":"conclusion 1","facts":[` + item(1) + `,` + item(2) + `]}`, false, 2, `"summary"`},
|
||||
}
|
||||
for _, s := range shapes {
|
||||
before := tools.Writes().Facts
|
||||
linked, _ := store.FactsYielded(intentID)
|
||||
res := callGuardTool(t, tool, s.call)
|
||||
written := tools.Writes().Facts - before
|
||||
if !res.IsError != s.accept {
|
||||
t.Errorf("%s: accepted=%v want %v: %s", s.name, !res.IsError, s.accept, res.Flatten())
|
||||
continue
|
||||
}
|
||||
if !s.accept {
|
||||
if written != 0 || !strings.Contains(res.Flatten(), "top-level field(s) "+s.fields) || !strings.Contains(res.Flatten(), "no facts were written") {
|
||||
t.Errorf("%s: refusal must write nothing and name %s: %s (writes %d)", s.name, s.fields, res.Flatten(), written)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if written != s.items {
|
||||
t.Errorf("%s: wrote %d facts for %d items", s.name, written, s.items)
|
||||
}
|
||||
after, _ := store.FactsYielded(intentID)
|
||||
if len(after) != len(linked)+s.items {
|
||||
t.Errorf("%s: intent links %d → %d for %d items", s.name, len(linked), len(after), s.items)
|
||||
}
|
||||
ids := after[len(linked):]
|
||||
if strings.HasPrefix(s.call, `{"facts"`) || strings.HasPrefix(s.call, `{"intent_id"`) {
|
||||
var out struct {
|
||||
IDs []int64 `json:"ids"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(res.Flatten()), &out); err != nil || len(out.IDs) != s.items {
|
||||
t.Errorf("%s: ids: %s", s.name, res.Flatten())
|
||||
}
|
||||
}
|
||||
for _, id := range ids {
|
||||
node, err := store.GetNode(id)
|
||||
if err != nil || node == nil || node.Kind != db.KindFact {
|
||||
t.Fatalf("%s: fact %d: %v", s.name, id, err)
|
||||
}
|
||||
var payload map[string]any
|
||||
_ = json.Unmarshal(node.Payload, &payload)
|
||||
if sum, _ := payload["summary"].(string); sum == "" || sum == "x" {
|
||||
t.Errorf("%s: stored summary %q", s.name, sum)
|
||||
}
|
||||
if strings.Contains(s.call, "asset_ids") {
|
||||
anchored := false
|
||||
for _, asset := range assets {
|
||||
refs, err := store.AssetRefs(asset)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, r := range refs {
|
||||
if r.ID == id {
|
||||
anchored = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if !anchored {
|
||||
t.Errorf("%s: fact %d not anchored to an asset", s.name, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ func TestIngestScanOutputPG(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
const assetsWhere = `ip IN ('198.51.100.77','2001:db8::77') OR domain LIKE '%scan-ingest.example.com' OR url LIKE '%198.51.100.77%' OR url LIKE '%2001:db8::77%'`
|
||||
const assetsWhere = `ip IN ('198.51.100.77','2001:db8::77') OR domain IN ('198.51.100.77','2001:db8::77','example.com') OR domain LIKE '%scan-ingest.example.com' OR url LIKE '%198.51.100.77%' OR url LIKE '%2001:db8::77%'`
|
||||
t.Cleanup(func() {
|
||||
_ = d.DeleteTask(task.ID)
|
||||
_, _ = d.Exec(`DELETE FROM assets WHERE ` + assetsWhere)
|
||||
@@ -127,7 +127,7 @@ func TestIngestScanOutputJSONPG(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
const assetsWhere = `domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`
|
||||
const assetsWhere = `ip IN ('198.51.100.77','2001:db8::77') OR domain IN ('198.51.100.77','2001:db8::77','example.com') OR domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`
|
||||
t.Cleanup(func() {
|
||||
_ = d.DeleteTask(task.ID)
|
||||
_, _ = d.Exec(`DELETE FROM assets WHERE ` + assetsWhere)
|
||||
@@ -210,7 +210,7 @@ func TestIngestScanOutputUserinfoPG(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
const assetsWhere = `domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`
|
||||
const assetsWhere = `ip IN ('198.51.100.77','2001:db8::77') OR domain IN ('198.51.100.77','2001:db8::77','example.com') OR domain LIKE '%scan-ingest.example.com' OR url LIKE '%scan-ingest.example.com%'`
|
||||
t.Cleanup(func() {
|
||||
_ = d.DeleteTask(task.ID)
|
||||
_, _ = d.Exec(`DELETE FROM assets WHERE ` + assetsWhere)
|
||||
|
||||
@@ -180,6 +180,14 @@ type overriddenTool struct {
|
||||
func (o *overriddenTool) Description() string { return o.desc }
|
||||
func (o *overriddenTool) InputSchema() map[string]any { return o.schema }
|
||||
|
||||
// AcceptsRawInput forwards the wrapped tool's opt-out of the harness schema
|
||||
// check (record_fact validates its own input); the embedded interface alone
|
||||
// would hide it from the harness's type assertion.
|
||||
func (o *overriddenTool) AcceptsRawInput() bool {
|
||||
r, ok := o.CoreTool.(interface{ AcceptsRawInput() bool })
|
||||
return ok && r.AcceptsRawInput()
|
||||
}
|
||||
|
||||
func (o *overriddenTool) Call(ctx context.Context, in json.RawMessage, tc *actool.ToolContext) (actool.Result, error) {
|
||||
return o.CoreTool.Call(ctx, injectDefaults(in, o.schema), tc)
|
||||
}
|
||||
|
||||
+44
-5
@@ -394,8 +394,21 @@ func readTool(name, desc string, schema map[string]any, run func(context.Context
|
||||
}
|
||||
|
||||
func writeTool(name, desc string, schema map[string]any, run func(context.Context, json.RawMessage) (actool.Result, error)) actool.CoreTool {
|
||||
return buildWriteTool(name, desc, schema, false, run)
|
||||
}
|
||||
|
||||
// writeRawTool is writeTool for a handler that validates its own input: the
|
||||
// harness skips its schema check (Spec.RawInput), so the published schema can
|
||||
// be stricter (required properties) than the legacy shapes the handler still
|
||||
// accepts, and refusals carry the handler's own message instead of the
|
||||
// SDK's generic one.
|
||||
func writeRawTool(name, desc string, schema map[string]any, run func(context.Context, json.RawMessage) (actool.Result, error)) actool.CoreTool {
|
||||
return buildWriteTool(name, desc, schema, true, run)
|
||||
}
|
||||
|
||||
func buildWriteTool(name, desc string, schema map[string]any, raw bool, run func(context.Context, json.RawMessage) (actool.Result, error)) actool.CoreTool {
|
||||
return actool.Build(actool.Spec{
|
||||
Name: name, Description: desc, Schema: schema,
|
||||
Name: name, Description: desc, Schema: schema, RawInput: raw,
|
||||
Permissions: func(context.Context, json.RawMessage, acperm.Context) acperm.Decision { return acperm.Allowed() },
|
||||
Run: func(ctx context.Context, in json.RawMessage, _ *actool.ToolContext) (actool.Result, error) {
|
||||
return run(ctx, in)
|
||||
@@ -419,6 +432,12 @@ func (t *ToolSet) writeExpTool(name, desc string, schema map[string]any, run fun
|
||||
return writeTool(name, desc, schema, t.needExploration(name, run))
|
||||
}
|
||||
|
||||
// writeExpToolRaw is writeExpTool with the harness schema check skipped (see
|
||||
// writeRawTool); the handler validates the input itself.
|
||||
func (t *ToolSet) writeExpToolRaw(name, desc string, schema map[string]any, run func(context.Context, json.RawMessage) (actool.Result, error)) actool.CoreTool {
|
||||
return writeRawTool(name, desc, schema, t.needExploration(name, run))
|
||||
}
|
||||
|
||||
// needExploration wraps a handler so it only runs with an exploration store.
|
||||
// Tools that degrade more usefully than "unavailable" (report_finding points at
|
||||
// add_task_hint, set_goals/set_constraints at the task itself) keep their own
|
||||
@@ -1588,15 +1607,30 @@ func (t *ToolSet) recordOneFact(it factItem, defaultIntent int64) (int64, error)
|
||||
return id, nil
|
||||
}
|
||||
|
||||
// runningIntent is the intent this ToolSet works for (the worker's claimed
|
||||
// intent, set by SetOwnerNode), or 0 when the owner node is not an intent
|
||||
// (planner: the task root) or unknown.
|
||||
func (t *ToolSet) runningIntent() int64 {
|
||||
if t.ts == nil || t.ownerNode <= 0 {
|
||||
return 0
|
||||
}
|
||||
node, err := t.ts.GetNode(t.ownerNode)
|
||||
if err != nil || node == nil || node.Kind != db.KindIntent {
|
||||
return 0
|
||||
}
|
||||
return node.ID
|
||||
}
|
||||
|
||||
func (t *ToolSet) recordFact() actool.CoreTool {
|
||||
return t.writeExpTool("record_fact", "Write an exploration [fact/conclusion] into the exploration graph, linked to the intent that produced it (intent_id). Used to record exploration results — both [positive conclusions] like fingerprinting/enumeration, and [negative conclusions] like 'port closed'/'parameter not injectable'/'no login entry found'.\n"+
|
||||
return t.writeExpToolRaw("record_fact", "Write an exploration [fact/conclusion] into the exploration graph, linked to the intent that produced it (intent_id). Used to record exploration results — both [positive conclusions] like fingerprinting/enumeration, and [negative conclusions] like 'port closed'/'parameter not injectable'/'no login entry found'.\n"+
|
||||
"⚠️Multiple observations from one exploration must be [consolidated into ONE fact], not split into many; whenever they can be merged into one fact, use one: summary = a one-sentence summary of this conclusion, detail = the related details (may contain multiple concrete items). Example: a fingerprinting intent → one fact {summary:'identified the tech stack and response characteristics of site X', detail:'nginx 1.25 / Vue3 / 200 / title=.. / body_len=..'}, rather than one fact each for status code, fingerprint, and title. One intent usually produces exactly one fact; splitting too finely bloats the graph endlessly.\n"+
|
||||
"★The facts array writes several [mutually distinct] conclusions at once (each may omit intent_id, defaulting to the top-level intent_id). Returns an ids array, same length and order as facts.\n"+
|
||||
"★facts is the only parameter: facts:[{...}] with one item per [mutually distinct] conclusion, usually exactly one item. Returns an ids array, same length and order as facts. An item without intent_id is linked to the intent you are running.\n"+
|
||||
"⚠️Write only conclusions you [actually saw] in tool output — don't extrapolate. evidence and confidence keep inaccurate conclusions from polluting the graph:\n"+
|
||||
" · evidence = [one line] of key evidence supporting this conclusion (the command + the one or two most proving output lines), **keep it brief** — details belong in detail; don't paste large output blocks here.\n"+
|
||||
" · confidence = observed (seen directly in output) | inferred (inferred from phenomena).\n"+
|
||||
" · source = where the content came from: target_response (content the target itself returned: page bodies, headers, error messages, banners, even when a tool fetched it) | tool_output (a tool's own result about the target: port states, scanner verdicts, status codes, timings) | third_party_intel (OSINT, CVE databases, public reports) | operator_input (given by the human operator) | inference (your own reasoning; the default when omitted). Any other value is refused.\n"+
|
||||
" · **Negative conclusions** (not injectable / port closed / no entry found, etc.) state only \"observation + tentative reading\" — state what you actually saw; whether to abandon the direction is for the planner to decide globally; always provide evidence, mark inferred when the means weren't exhausted or the evidence is weak (including probed only once, looks-like), and mark observed only when truly exhausted and directly seen.",
|
||||
" · **Negative conclusions** (not injectable / port closed / no entry found, etc.) state only \"observation + tentative reading\" — state what you actually saw; whether to abandon the direction is for the planner to decide globally; always provide evidence, mark inferred when the means weren't exhausted or the evidence is weak (including probed only once, looks-like), and mark observed only when truly exhausted and directly seen."+
|
||||
recordFactContractNote,
|
||||
recordFactSchema(),
|
||||
func(_ context.Context, in json.RawMessage) (actool.Result, error) {
|
||||
a, batch, err := decodeRecordFactInput(in)
|
||||
@@ -1607,7 +1641,12 @@ func (t *ToolSet) recordFact() actool.CoreTool {
|
||||
if !batch {
|
||||
items = []factItem{a.factItem}
|
||||
}
|
||||
defaultIntent := pid(a.factItem.IntentID) // top-level intent_id = batch default
|
||||
// Default intent of the items: a legacy top-level intent_id, else the
|
||||
// intent this worker is running (the published schema has no top level).
|
||||
defaultIntent := pid(a.factItem.IntentID)
|
||||
if defaultIntent <= 0 {
|
||||
defaultIntent = t.runningIntent()
|
||||
}
|
||||
|
||||
ids := make([]int64, len(items))
|
||||
errs := map[string]string{}
|
||||
|
||||
@@ -118,7 +118,7 @@ else
|
||||
command -v rsync >/dev/null 2>&1 || die "rsync not detected"
|
||||
info "Building frontend static assets"
|
||||
if [ "${ARTEX_SKIP_NPM_CI:-0}" != "1" ]; then
|
||||
(cd web && npm ci)
|
||||
(cd web && npm ci --ignore-scripts)
|
||||
fi
|
||||
(cd web && npm run build:static)
|
||||
info "Syncing frontend assets to server/webui/dist"
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestFlushActivityOutboxReplaysOnce(t *testing.T) {
|
||||
if err != nil {
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
t.Cleanup(func() { _ = d.Close() })
|
||||
expID, err := d.CreateExploration("outbox", "replay")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -65,7 +65,7 @@ func TestFlushActivityOutboxDropsStuckRow(t *testing.T) {
|
||||
if err != nil {
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
t.Cleanup(func() { _ = d.Close() })
|
||||
const missing = int64(9_000_000_000_001)
|
||||
t.Cleanup(func() { _, _ = d.Exec(`DELETE FROM activity_outbox WHERE exploration_id=$1`, missing) })
|
||||
es := d.Exploration(missing)
|
||||
|
||||
@@ -1143,6 +1143,7 @@ func TestAssetIPRejectsHostname(t *testing.T) {
|
||||
t.Fatalf("empty ip rejected: %v", err)
|
||||
}
|
||||
deleteAsset(d, id)
|
||||
_, _ = d.Exec(`DELETE FROM assets WHERE domain IN ('ip-guard.example.com','example.com')`)
|
||||
id, err = av2.UpsertIP(UpsertIPReq{IP: "203.0.113.7"})
|
||||
if err != nil {
|
||||
t.Fatalf("valid ip rejected: %v", err)
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestDashboardUsageIndexesMigration0010(t *testing.T) {
|
||||
d, err := Open(testDSN(t))
|
||||
if err != nil {
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { _ = d.Close() })
|
||||
|
||||
wantIndexes := []struct {
|
||||
name string
|
||||
table string
|
||||
pred string
|
||||
}{
|
||||
{"idx_act_result_created", "activity", "kind = 'result'"},
|
||||
{"idx_conv_act_result", "conversation_activities", "kind = 'result'"},
|
||||
{"idx_llm_usage_judge_ts", "llm_usage", "worker = 'judge'"},
|
||||
}
|
||||
|
||||
for _, want := range wantIndexes {
|
||||
var valid, ready bool
|
||||
var def string
|
||||
err := d.QueryRow(`
|
||||
SELECT i.indisvalid, i.indisready, pg_get_indexdef(i.indexrelid)
|
||||
FROM pg_index i
|
||||
JOIN pg_class c ON c.oid = i.indexrelid
|
||||
JOIN pg_namespace n ON n.oid = c.relnamespace
|
||||
WHERE n.nspname = 'public' AND c.relname = $1`, want.name).Scan(&valid, &ready, &def)
|
||||
if err != nil {
|
||||
t.Fatalf("index public.%s missing after Open: %v", want.name, err)
|
||||
}
|
||||
if !valid || !ready {
|
||||
t.Fatalf("index %s indisvalid=%v indisready=%v, want both true (%s)", want.name, valid, ready, def)
|
||||
}
|
||||
if !strings.Contains(def, want.table) || !strings.Contains(def, want.pred) {
|
||||
t.Fatalf("index %s definition %q missing table %q or predicate %q", want.name, def, want.table, want.pred)
|
||||
}
|
||||
}
|
||||
|
||||
// Verify sargable TokenByModel matches both specific task_id and empty task_id.
|
||||
taskID := fmt.Sprintf("idx-test-%d", time.Now().UnixNano())
|
||||
t.Cleanup(func() {
|
||||
_, _ = d.Exec(`DELETE FROM llm_usage WHERE task_id = $1 OR profile_name = $2`, taskID, taskID)
|
||||
})
|
||||
if err := d.InsertLLMUsage(&LLMUsage{
|
||||
TaskID: taskID,
|
||||
Worker: "worker",
|
||||
Model: "claude-sonnet-4",
|
||||
ProfileName: taskID,
|
||||
InputTokens: 1000,
|
||||
OutputTokens: 200,
|
||||
Status: "ok",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := d.InsertLLMUsage(&LLMUsage{
|
||||
TaskID: "",
|
||||
Worker: "chat",
|
||||
Model: "gpt-5",
|
||||
ProfileName: taskID,
|
||||
InputTokens: 500,
|
||||
OutputTokens: 100,
|
||||
Status: "ok",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
got, err := d.TokenByModel(taskID)
|
||||
if err != nil {
|
||||
t.Fatalf("TokenByModel(%q): %v", taskID, err)
|
||||
}
|
||||
if len(got) != 1 || got[0].Model != "claude-sonnet-4" || got[0].InputTokens != 1000 || got[0].OutputTokens != 200 {
|
||||
t.Fatalf("TokenByModel(%q) = %+v, want 1 claude-sonnet-4 row", taskID, got)
|
||||
}
|
||||
|
||||
emptyGot, err := d.TokenByModel("")
|
||||
if err != nil {
|
||||
t.Fatalf("TokenByModel(\"\"): %v", err)
|
||||
}
|
||||
foundChat := false
|
||||
for _, m := range emptyGot {
|
||||
if m.Model == "gpt-5" && m.InputTokens >= 500 {
|
||||
foundChat = true
|
||||
}
|
||||
}
|
||||
if !foundChat {
|
||||
t.Fatalf("TokenByModel(\"\") did not include NULL/empty task_id row: %+v", emptyGot)
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ func TestFindingQualityByNodeID(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteFinding(rec.FindingID)
|
||||
if err := d.SetFindingVerification(rec.FindingID, VerificationVerified, 3, "reproduced twice on staging"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -24,10 +24,12 @@ func TestFindingReasoningFieldsRoundTrip(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteFinding(with.FindingID)
|
||||
without, err := es.RecordFinding(t.Context(), RecordFindingInput{TaskID: tk.ID, VulnClass: "IDOR", Severity: "low", Summary: "without reasoning", Worker: "test"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteFinding(without.FindingID)
|
||||
want := map[int64][2]string{
|
||||
with.FindingID: {"UUID guessing returned 404", "two accounts, same response body"},
|
||||
without.FindingID: {"", ""},
|
||||
|
||||
@@ -32,7 +32,11 @@ func TestFindingTrafficLegacyArchiveDefaults(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { d.Exec(`DELETE FROM task_archives WHERE task_id=$1`, task.ID); d.DeleteTask(task.ID) }()
|
||||
defer func() {
|
||||
_, _ = d.DeleteFindingsByTask(task.ID)
|
||||
_, _ = d.Exec(`DELETE FROM task_archives WHERE task_id=$1`, task.ID)
|
||||
_ = d.DeleteTask(task.ID)
|
||||
}()
|
||||
f, err := d.Exploration(task.ExplorationID).RecordFinding(t.Context(), RecordFindingInput{TaskID: task.ID, ExplorationID: task.ExplorationID, Summary: "legacy", Severity: "low"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
+9
-3
@@ -100,6 +100,7 @@ func TestSetFindingStatusMirrorsNodePayload(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteFinding(fid)
|
||||
|
||||
n, err := d.SetFindingStatus(fid, FindingFalsePositive)
|
||||
if err != nil || n != 1 {
|
||||
@@ -146,13 +147,13 @@ func TestFindingReportState(t *testing.T) {
|
||||
if err != nil {
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
t.Cleanup(func() { d.Close() })
|
||||
|
||||
tk, err := d.CreateTask("finding report state", "goal", nil, 0, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteTask(tk.ID)
|
||||
t.Cleanup(func() { _ = d.DeleteTask(tk.ID) })
|
||||
|
||||
es := d.Exploration(tk.ExplorationID)
|
||||
nodeID, err := es.AddNode(KindFinding, map[string]any{"summary": "x", "severity": "high"}, 5, "confirmed", "worker", nil)
|
||||
@@ -167,7 +168,11 @@ func TestFindingReportState(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { d.Exec(`DELETE FROM notification_events WHERE finding_id IN ($1,$2)`, fid, second) })
|
||||
t.Cleanup(func() {
|
||||
_, _ = d.Exec(`DELETE FROM notification_events WHERE finding_id IN ($1,$2)`, fid, second)
|
||||
_, _ = d.DeleteFinding(fid)
|
||||
_, _ = d.DeleteFinding(second)
|
||||
})
|
||||
|
||||
one, err := d.GetFinding(fid)
|
||||
if err != nil || one == nil || one.ReportState != FindingReportNone {
|
||||
@@ -633,6 +638,7 @@ func TestAddFindingFollowUpIntent(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteFinding(findingID)
|
||||
|
||||
auditInput := Activity{Worker: "system", Kind: "text", Summary: "Manually submitted vulnerability deep-exploitation intent", Detail: "Verify exploitability and build an evidence chain"}
|
||||
intentID, audit, err := store.AddFindingFollowUpIntent(findingID, findingNodeID, "Verify exploitability and build an evidence chain", auditInput)
|
||||
|
||||
+12
-2
@@ -191,11 +191,14 @@ func TestExtractLessonsScopesSingleCompanyFromTaskScope(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { cleanupErr(t, "extract task", d.DeleteTask(task.ID)) })
|
||||
if _, err := d.Exec(`
|
||||
var extractedFID int64
|
||||
if err := d.QueryRow(`
|
||||
INSERT INTO findings(task_id,vulnclass,name,summary,severity,status)
|
||||
VALUES ($1,'xss','Reflected XSS','reflected in search','high','confirmed')`, task.ID); err != nil {
|
||||
VALUES ($1,'xss','Reflected XSS','reflected in search','high','confirmed')
|
||||
RETURNING id`, task.ID).Scan(&extractedFID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, extractedFID) })
|
||||
n, err := d.ExtractLessonsForTask(t.Context(), task.ID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -477,6 +480,7 @@ func TestExtractLessonsRetractsReversedDisposition(t *testing.T) {
|
||||
RETURNING id`, task.ID, cue, label).Scan(&fid); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, fid) })
|
||||
|
||||
n, err := d.ExtractLessonsForTask(t.Context(), task.ID)
|
||||
if err != nil {
|
||||
@@ -589,12 +593,14 @@ func TestExtractLessonsRetireOnlyWhenLastEvidence(t *testing.T) {
|
||||
RETURNING id`, task.ID, cue, label).Scan(&aID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, aID) })
|
||||
if err := d.QueryRow(`
|
||||
INSERT INTO findings(task_id,vulnclass,name,summary,severity,status)
|
||||
VALUES ($1,$2,'Reflected XSS',$3,'high','confirmed')
|
||||
RETURNING id`, task.ID, cue, label).Scan(&bID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, bID) })
|
||||
|
||||
if _, err := d.ExtractLessonsForTask(t.Context(), task.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -681,6 +687,7 @@ func TestExtractLessonsRetractsAllRetests(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, fid) })
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, fid) })
|
||||
|
||||
r1 := insertLessonRetest(t, d, fid, "reproduced")
|
||||
if _, err := d.ExtractLessonsForTask(t.Context(), task.ID); err != nil {
|
||||
@@ -752,6 +759,7 @@ func TestExtractLessonsDoesNotUnretireWithEvidence(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, fid) })
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, fid) })
|
||||
|
||||
if _, err := d.ExtractLessonsForTask(t.Context(), task.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -798,6 +806,7 @@ func TestExtractLessonsLeavesAdopted(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, fid) })
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, fid) })
|
||||
|
||||
if _, err := d.ExtractLessonsForTask(t.Context(), task.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -841,6 +850,7 @@ func TestExtractLessonsReopenRetractsNothing(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, fid) })
|
||||
t.Cleanup(func() { cleanupExec(t, d, `DELETE FROM findings WHERE id=$1`, fid) })
|
||||
|
||||
if _, err := d.ExtractLessonsForTask(t.Context(), task.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
+21
-2
@@ -1,6 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -71,14 +72,32 @@ VALUES (NULLIF($1,''),$2,NULLIF($3,''),NULLIF($4,''),NULLIF($5,''),$6,$7,$8,$9,$
|
||||
// Accurate even with per-agent model bindings, pool rotation/failover, and
|
||||
// interrupted runs, since every call (success or error) is metered.
|
||||
func (d *DB) TokenByModel(taskID string) ([]ModelTokenStat, error) {
|
||||
rows, err := d.Query(`
|
||||
// Keep the predicate sargable for non-empty task IDs so PostgreSQL can use
|
||||
// idx_llm_usage_model(task_id, model) instead of sequentially scanning the
|
||||
// table via COALESCE(task_id, '').
|
||||
var (
|
||||
rows *sql.Rows
|
||||
err error
|
||||
)
|
||||
if taskID == "" {
|
||||
rows, err = d.Query(`
|
||||
SELECT COALESCE(NULLIF(model,''),'(unknown)') AS model, COUNT(*) AS calls,
|
||||
COALESCE(SUM(input_tokens),0), COALESCE(SUM(output_tokens),0),
|
||||
COALESCE(SUM(cache_read),0), COALESCE(SUM(cache_write),0)
|
||||
FROM llm_usage
|
||||
WHERE COALESCE(task_id,'') = $1
|
||||
WHERE task_id IS NULL OR task_id = ''
|
||||
GROUP BY model
|
||||
ORDER BY SUM(input_tokens) + SUM(output_tokens) DESC, model`)
|
||||
} else {
|
||||
rows, err = d.Query(`
|
||||
SELECT COALESCE(NULLIF(model,''),'(unknown)') AS model, COUNT(*) AS calls,
|
||||
COALESCE(SUM(input_tokens),0), COALESCE(SUM(output_tokens),0),
|
||||
COALESCE(SUM(cache_read),0), COALESCE(SUM(cache_write),0)
|
||||
FROM llm_usage
|
||||
WHERE task_id = $1
|
||||
GROUP BY model
|
||||
ORDER BY SUM(input_tokens) + SUM(output_tokens) DESC, model`, taskID)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestCostSeparatesFreshReadAndWriteBuckets(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.Close()
|
||||
t.Cleanup(func() { d.Close() })
|
||||
priced, unpriced := costProfiles(t, d)
|
||||
// Every case adds 100k output tokens: 0.1 × 4.00 = 0.40.
|
||||
for _, tc := range []struct {
|
||||
@@ -82,7 +82,7 @@ func TestUsageByProfileCostAggregatesRows(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.Close()
|
||||
t.Cleanup(func() { d.Close() })
|
||||
priced, unpriced := costProfiles(t, d)
|
||||
t.Cleanup(func() { d.Exec(`DELETE FROM llm_usage WHERE profile_name IN ($1,$2)`, priced, unpriced) })
|
||||
rows := []LLMUsage{
|
||||
|
||||
+2
-2
@@ -138,9 +138,9 @@ func assertEmbeddedApplied(t *testing.T, d *DB) []appliedMigration {
|
||||
name string
|
||||
}{{1, llmRecordsMigration}, {2, llmUsageMigration}, {3, "0003_task_scope_icp_index.sql"}, {4, "0004_llm_usage_ts_index.sql"},
|
||||
{5, "0005_traffic_rewrite_rules.sql"}, {6, "0006_activity_outbox.sql"}, {7, "0007_finding_report_state.sql"},
|
||||
{8, "0008_traffic_evidence_rewrite_flag.sql"}, {9, "0009_llm_context.sql"}}
|
||||
{8, "0008_traffic_evidence_rewrite_flag.sql"}, {9, "0009_llm_context.sql"}, {10, "0010_dashboard_usage_indexes.sql"}}
|
||||
if len(applied) != len(want) {
|
||||
t.Fatalf("schema_migrations = %+v, want versions 1 to 9", applied)
|
||||
t.Fatalf("schema_migrations = %+v, want versions 1 to 10", applied)
|
||||
}
|
||||
for i, w := range want {
|
||||
content, err := fs.ReadFile(migrationsFS(), w.name)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
-- Partial covering indexes proved via EXPLAIN (ANALYZE, BUFFERS) on seeded
|
||||
-- production-shaped tables (P3.6 dashboard & usage query hygiene):
|
||||
--
|
||||
-- 1. idx_act_result_created: TokenDailyAll (db/exploration.go) aggregates
|
||||
-- activity WHERE kind='result' AND created_at >= now() - interval. The
|
||||
-- existing idx_act_result_usage is keyed on exploration_id, so date-bounded
|
||||
-- global daily rollups previously fell back to a bitmap heap scan across all
|
||||
-- result rows (~100x fewer shared buffers with an index-only scan).
|
||||
-- 2. idx_conv_act_result: ConversationTokenSummaries (db/conversation.go,
|
||||
-- polled every 5s by the dashboard) left-joins conversation_activities on
|
||||
-- (conversation_id) WHERE kind='result'. Without a partial index on
|
||||
-- kind='result', every poll sequentially scans the entire
|
||||
-- conversation_activities table (~65x fewer shared buffers).
|
||||
-- 3. idx_llm_usage_judge_ts: JudgeUsageStats (db/llm_usage.go) filters
|
||||
-- llm_usage WHERE worker='judge' (all-time and recent window). Judge rows
|
||||
-- are a small fraction of the append-only ledger; a partial covering index
|
||||
-- turns both queries into index-only scans (~60-80x fewer shared buffers).
|
||||
--
|
||||
-- Plain CREATE INDEX (migrations run in a transaction at startup before the
|
||||
-- HTTP server listens). Very large installs can pre-build them online with
|
||||
-- CREATE INDEX CONCURRENTLY IF NOT EXISTS before upgrading.
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_act_result_created
|
||||
ON activity(created_at)
|
||||
INCLUDE (input_tokens, output_tokens, cache_read_tokens)
|
||||
WHERE kind = 'result';
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_conv_act_result
|
||||
ON conversation_activities(conversation_id)
|
||||
INCLUDE (input_tokens, output_tokens, cache_read_tokens, cache_write_tokens)
|
||||
WHERE kind = 'result';
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_llm_usage_judge_ts
|
||||
ON llm_usage(ts)
|
||||
INCLUDE (input_tokens, output_tokens, cache_read, cache_write)
|
||||
WHERE worker = 'judge';
|
||||
+17
-6
@@ -534,7 +534,7 @@ func TestSetFindingStatusWithNotifyOnlyEmitsOnRealChange(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteTask(tk.ID)
|
||||
t.Cleanup(func() { _ = d.DeleteTask(tk.ID) })
|
||||
es := d.Exploration(tk.ExplorationID)
|
||||
f, err := es.RecordFinding(ctx, RecordFindingInput{
|
||||
TaskID: tk.ID, Worker: "test", VulnClass: "SQL injection", Name: "status change case",
|
||||
@@ -543,7 +543,10 @@ func TestSetFindingStatusWithNotifyOnlyEmitsOnRealChange(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { d.Exec(`DELETE FROM notification_events WHERE finding_id=$1`, f.FindingID) })
|
||||
t.Cleanup(func() {
|
||||
_, _ = d.Exec(`DELETE FROM notification_events WHERE finding_id=$1`, f.FindingID)
|
||||
_, _ = d.DeleteFinding(f.FindingID)
|
||||
})
|
||||
|
||||
// Writing the finding already registered one finding_created event; count it as the baseline.
|
||||
var base int
|
||||
@@ -617,7 +620,7 @@ func TestSetFindingStatusesWithNotify(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteTask(tk.ID)
|
||||
t.Cleanup(func() { _ = d.DeleteTask(tk.ID) })
|
||||
es := d.Exploration(tk.ExplorationID)
|
||||
record := func(name string) int64 {
|
||||
fi, err := es.RecordFinding(ctx, RecordFindingInput{
|
||||
@@ -627,7 +630,10 @@ func TestSetFindingStatusesWithNotify(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { d.Exec(`DELETE FROM notification_events WHERE finding_id=$1`, fi.FindingID) })
|
||||
t.Cleanup(func() {
|
||||
_, _ = d.Exec(`DELETE FROM notification_events WHERE finding_id=$1`, fi.FindingID)
|
||||
_, _ = d.DeleteFinding(fi.FindingID)
|
||||
})
|
||||
return fi.FindingID
|
||||
}
|
||||
first, second := record("bulk one"), record("bulk two")
|
||||
@@ -891,7 +897,7 @@ func TestFinishFindingRetestEmitsStatusChange(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer d.DeleteTask(tk.ID)
|
||||
t.Cleanup(func() { _ = d.DeleteTask(tk.ID) })
|
||||
es := d.Exploration(tk.ExplorationID)
|
||||
f, err := es.RecordFinding(ctx, RecordFindingInput{
|
||||
TaskID: tk.ID, Worker: "test", VulnClass: "SQL injection", Name: "retest target",
|
||||
@@ -900,7 +906,10 @@ func TestFinishFindingRetestEmitsStatusChange(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { d.Exec(`DELETE FROM notification_events WHERE finding_id=$1`, f.FindingID) })
|
||||
t.Cleanup(func() {
|
||||
_, _ = d.Exec(`DELETE FROM notification_events WHERE finding_id=$1`, f.FindingID)
|
||||
_, _ = d.DeleteFinding(f.FindingID)
|
||||
})
|
||||
|
||||
// Create a retest record and drive it straight to completion.
|
||||
rt, _, _, err := d.CreateFindingRetest(ctx, f.FindingID, "review")
|
||||
@@ -910,6 +919,8 @@ func TestFinishFindingRetestEmitsStatusChange(t *testing.T) {
|
||||
if rt.ConversationID == nil {
|
||||
t.Fatal("a retest should be associated with a session")
|
||||
}
|
||||
retestConvID := *rt.ConversationID
|
||||
t.Cleanup(func() { _ = d.DeleteConversation(retestConvID) })
|
||||
// A retest must enter running before a verdict can land (consistent with the real flow).
|
||||
if ok, err := d.StartFindingRetest(ctx, rt.ID); err != nil || !ok {
|
||||
t.Fatalf("failed to start retest: ok=%v err=%v", ok, err)
|
||||
|
||||
@@ -154,19 +154,28 @@ func TestTaskArchiveDatabaseRoundTrip(t *testing.T) {
|
||||
VALUES($1,$2,0,'quota_exhausted','balance exhausted',$3,$4,$3)`, task.ID, llmProfileID, exhaustedAt, chainCreatedAt); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var assetID, findingID int64
|
||||
defer func() {
|
||||
_, _ = d.Exec(`DELETE FROM llm_usage WHERE task_id=$1 OR exploration_id=$2`, fmt.Sprint(task.ID), task.ExplorationID)
|
||||
_, _ = d.Exec(`DELETE FROM llm_records WHERE task_id=$1`, fmt.Sprint(task.ID))
|
||||
_, _ = d.Exec(`DELETE FROM skill_usage WHERE task_id=$1 OR exploration_id=$2`, task.ID, task.ExplorationID)
|
||||
_, _ = d.Exec(`DELETE FROM tool_usage WHERE task_id=$1 OR exploration_id=$2`, task.ID, task.ExplorationID)
|
||||
_, _ = d.DeleteFindingsByTask(task.ID)
|
||||
if findingID != 0 {
|
||||
_, _ = d.DeleteFinding(findingID)
|
||||
}
|
||||
_, _ = d.Exec(`DELETE FROM task_archives WHERE task_id=$1`, task.ID)
|
||||
_ = d.DeleteTask(task.ID)
|
||||
if assetID != 0 {
|
||||
_, _ = d.Exec(`DELETE FROM assets WHERE id=$1`, assetID)
|
||||
}
|
||||
_, _ = d.Exec(`DELETE FROM llm_profiles WHERE id=$1`, llmProfileID)
|
||||
_, _ = d.Exec(`DELETE FROM companies WHERE id=$1`, companyID)
|
||||
}()
|
||||
if err := d.SetPaused(task.ID, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assetID, err := d.Assets().UpsertRootDomain(UpsertRootDomainReq{Domain: fmt.Sprintf("archive-%d.example", task.ID), TaskID: task.ID})
|
||||
assetID, err = d.Assets().UpsertRootDomain(UpsertRootDomainReq{Domain: fmt.Sprintf("archive-%d.example", task.ID), TaskID: task.ID})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -197,7 +206,7 @@ VALUES($1,$2,0,'quota_exhausted','balance exhausted',$3,$4,$3)`, task.ID, llmPro
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := d.AddFinding(task.ID, nodeID, vulnclass, "archive finding", SeverityCritical, "summary", "evidence", "worker", []int64{assetID}); err != nil {
|
||||
if findingID, err = d.AddFinding(task.ID, nodeID, vulnclass, "archive finding", SeverityCritical, "summary", "evidence", "worker", []int64{assetID}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
archive, err := d.QueueTaskArchive(task.ID)
|
||||
|
||||
@@ -168,8 +168,9 @@ func TestIntentAssetsIncludesDirectSourceProvenance(t *testing.T) {
|
||||
cleanupErr(t, "source task", d.DeleteTask(source.ID))
|
||||
})
|
||||
|
||||
intentHost := fmt.Sprintf("intent-%d.example.test", time.Now().UnixNano())
|
||||
assetID, err := d.Assets().UpsertHTTPService(UpsertHTTPServiceReq{
|
||||
URL: fmt.Sprintf("https://intent-%d.example.test", time.Now().UnixNano()), TaskID: source.ID,
|
||||
URL: "https://" + intentHost, TaskID: source.ID,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -177,6 +178,9 @@ func TestIntentAssetsIncludesDirectSourceProvenance(t *testing.T) {
|
||||
t.Cleanup(func() {
|
||||
_, err := d.Assets().DeleteByIDs([]int64{assetID})
|
||||
cleanupErr(t, "asset", err)
|
||||
// UpsertHTTPService also creates the parent subdomain and root_domain rows.
|
||||
_, err = d.Exec(`DELETE FROM assets WHERE domain IN ($1, 'example.test')`, intentHost)
|
||||
cleanupErr(t, "parent assets", err)
|
||||
})
|
||||
intentID, err := d.Exploration(source.ExplorationID).AddIntent(map[string]any{"summary": "source worker"}, 5, []int64{assetID}, "planner")
|
||||
if err != nil {
|
||||
|
||||
@@ -13,7 +13,7 @@ func TestTaskLLMSpendCountsJudgeNotChat(t *testing.T) {
|
||||
if err != nil {
|
||||
SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer d.Close()
|
||||
t.Cleanup(func() { _ = d.Close() })
|
||||
|
||||
taskID := fmt.Sprintf("spend-%d", time.Now().UnixNano())
|
||||
t.Cleanup(func() {
|
||||
|
||||
@@ -38,6 +38,8 @@ services:
|
||||
ARTEX_LLM_MODEL: ${ARTEX_LLM_MODEL:-}
|
||||
ARTEX_LLM_BASE_URL: ${ARTEX_LLM_BASE_URL:-}
|
||||
ARTEX_LLM_PROXY: ${ARTEX_LLM_PROXY:-}
|
||||
# Exact host:port list the model-list fetch may reach on private addresses (e.g. host.docker.internal:11434 for Ollama).
|
||||
ARTEX_LLM_PRIVATE_ENDPOINTS: ${ARTEX_LLM_PRIVATE_ENDPOINTS:-}
|
||||
ARTEX_JWT_KEY_DIR: /app/keys
|
||||
# Optional: key for secrets at rest; empty = keys/secret.key (generated at first start).
|
||||
ARTEX_SECRET_KEY: ${ARTEX_SECRET_KEY:-}
|
||||
|
||||
@@ -281,20 +281,6 @@ func hostOf(rawURL string) string {
|
||||
return u.Hostname()
|
||||
}
|
||||
|
||||
func isBlank(v any) bool {
|
||||
switch x := v.(type) {
|
||||
case nil:
|
||||
return true
|
||||
case string:
|
||||
return x == ""
|
||||
case float64:
|
||||
return x == 0
|
||||
case int:
|
||||
return x == 0
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func uniq(in []string) []string {
|
||||
seen := map[string]struct{}{}
|
||||
out := in[:0]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/Autumn-27/artex
|
||||
|
||||
go 1.26.10
|
||||
go 1.26.11
|
||||
|
||||
require (
|
||||
github.com/Autumn-27/norma v0.4.11
|
||||
@@ -13,19 +13,19 @@ require (
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/jackc/pgx/v5 v5.10.0
|
||||
github.com/klauspost/compress v1.18.6
|
||||
github.com/klauspost/compress v1.20.2
|
||||
github.com/lqqyt2423/go-mitmproxy v1.9.2
|
||||
github.com/miekg/dns v1.1.72
|
||||
github.com/projectdiscovery/dnsx v1.2.3
|
||||
golang.org/x/crypto v0.58.0
|
||||
golang.org/x/crypto v0.59.0
|
||||
golang.org/x/net v0.62.0
|
||||
golang.org/x/text v0.43.0
|
||||
golang.org/x/text v0.44.0
|
||||
modernc.org/sqlite v1.52.0
|
||||
mvdan.cc/sh/v3 v3.14.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/andybalholm/brotli v1.2.1 // indirect
|
||||
github.com/andybalholm/brotli v1.2.7 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.25 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.5 // indirect
|
||||
@@ -70,10 +70,10 @@ require (
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
|
||||
golang.org/x/mod v0.41.0 // indirect
|
||||
golang.org/x/sync v0.24.0 // indirect
|
||||
golang.org/x/sys v0.49.0 // indirect
|
||||
golang.org/x/tools v0.51.0 // indirect
|
||||
golang.org/x/mod v0.42.0 // indirect
|
||||
golang.org/x/sync v0.25.0 // indirect
|
||||
golang.org/x/sys v0.50.0 // indirect
|
||||
golang.org/x/tools v0.52.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
modernc.org/libc v1.72.3 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
github.com/BaaRai/Norma v0.4.11 h1:Z5lSRFKBDI0EzAw1YDA5iQ5GXsa9e7J19YmIe0zaVcQ=
|
||||
github.com/BaaRai/Norma v0.4.11/go.mod h1:BudWrf7iHl96FgHqFr/HwN3mKYmGjJDt+xL2ZHXfFZw=
|
||||
github.com/andybalholm/brotli v1.2.1 h1:R+f5xP285VArJDRgowrfb9DqL18yVK0gKAW/F+eTWro=
|
||||
github.com/andybalholm/brotli v1.2.1/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
|
||||
github.com/andybalholm/brotli v1.2.7 h1:UgafRPGMam5ySHfRkhthMqOFA6IFoeF3D7mWIDLjG5A=
|
||||
github.com/andybalholm/brotli v1.2.7/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
||||
github.com/aws/aws-sdk-go-v2 v1.47.5 h1:5yA+A+BiXbDq1ZLbYwPViwhEGDMdR0MEhL8Jh2LnLS4=
|
||||
@@ -81,8 +81,8 @@ github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
|
||||
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao=
|
||||
github.com/klauspost/compress v1.18.6/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/klauspost/compress v1.20.2 h1:v5tiZvm1KGLyg5d5oXdXe3lsSPrbEUiKoXGia//I7Qo=
|
||||
github.com/klauspost/compress v1.20.2/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
@@ -143,23 +143,23 @@ go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54=
|
||||
golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w=
|
||||
golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c=
|
||||
golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
|
||||
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA=
|
||||
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
|
||||
golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
|
||||
golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
|
||||
golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg=
|
||||
golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs=
|
||||
golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY=
|
||||
golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
||||
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
||||
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
|
||||
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
|
||||
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
|
||||
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
|
||||
golang.org/x/tools v0.51.0 h1:k4Xc/1Om9jwkBJBo4NVLMSARBoWtK10mx+W5BnXCeAI=
|
||||
golang.org/x/tools v0.51.0/go.mod h1:9eEncMayCV6zRMGhR5eZEC2iBx98qWcF1HZ9Z7wJOoA=
|
||||
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
|
||||
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
|
||||
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
|
||||
golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs=
|
||||
golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ JSON
|
||||
# embedding the frontend requires node to produce the static assets
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
info "building frontend static assets..."
|
||||
( cd web && npm ci && npm run build:static )
|
||||
( cd web && npm ci --ignore-scripts && npm run build:static )
|
||||
rm -rf server/webui/dist && cp -r web/out server/webui/dist
|
||||
info "compiling embedded single binary..."
|
||||
CGO_ENABLED=0 go build -tags embedui -trimpath -o artex ./cmd/artex
|
||||
|
||||
@@ -6,6 +6,7 @@ package llmrec
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"iter"
|
||||
"log"
|
||||
"strings"
|
||||
@@ -16,6 +17,11 @@ import (
|
||||
"github.com/Autumn-27/norma/transcript"
|
||||
)
|
||||
|
||||
// errStreamAbandoned marks a stream whose consumer stopped reading before
|
||||
// message_stop while its context was still live. The call did not complete,
|
||||
// so it is metered as an error rather than inferred from ctx.Err().
|
||||
var errStreamAbandoned = errors.New("llmrec: consumer stopped reading before message_stop")
|
||||
|
||||
type taskIDContextKey struct{}
|
||||
type workerContextKey struct{}
|
||||
|
||||
@@ -190,6 +196,7 @@ func (r *Recorder) Stream(ctx context.Context, req llm.CompletionRequest) iter.S
|
||||
usage llm.Usage
|
||||
stopReason string
|
||||
streamErr error
|
||||
complete bool // message_stop was seen
|
||||
)
|
||||
|
||||
finished := false
|
||||
@@ -246,8 +253,21 @@ func (r *Recorder) Stream(ctx context.Context, req llm.CompletionRequest) iter.S
|
||||
stopReason = ev.StopReason
|
||||
}
|
||||
usage.MergeEcho(ev.Usage)
|
||||
case llm.SEMessageStop:
|
||||
complete = true
|
||||
}
|
||||
if !yield(ev, err) {
|
||||
// The consumer stopped early. Decide the status here from what
|
||||
// is known, not later in the deferred finish: the call only
|
||||
// counts as "ok" if message_stop arrived and ctx is live.
|
||||
switch {
|
||||
case ctx.Err() != nil:
|
||||
finish(ctx.Err())
|
||||
case !complete:
|
||||
finish(errStreamAbandoned)
|
||||
default:
|
||||
finish(nil)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
+12
-14
@@ -151,15 +151,9 @@ func (meteredStreamProvider) Stream(context.Context, llm.CompletionRequest) iter
|
||||
}
|
||||
|
||||
func TestSideUsageRecordedOnceOnConsumerCancellation(t *testing.T) {
|
||||
// Timing-sensitive on 2-core CI runners (BaaRai/ARTEX#9). Repro:
|
||||
// ARTEX_PG_DSN=postgres://artex:testpass@localhost:5432/artextest_race \
|
||||
// go test ./llmrec -run TestSideUsageRecordedOnceOnConsumerCancellation -count=20 -race -v
|
||||
// The `early=` t.Fatalf assertion below compares the single llm_usage row's
|
||||
// count/input/output/worker/status; in the `early` branch the status
|
||||
// occasionally comes back "ok" instead of "error" because the consumer's
|
||||
// cancellation and the recorder's deferred finish race on a loaded runner.
|
||||
// Keep the skip until the metering status is made cancellation-explicit.
|
||||
t.Skip("timing-sensitive on CI runners; repro and failing assertion documented above; BaaRai/ARTEX#9")
|
||||
// Previously skipped as timing-sensitive (BaaRai/ARTEX#9). The recorder now
|
||||
// decides the status at the point the consumer stops, so the result no
|
||||
// longer depends on when the deferred finish runs.
|
||||
dsn := os.Getenv("ARTEX_PG_DSN")
|
||||
if dsn == "" {
|
||||
t.Skip("requires isolated ARTEX_PG_DSN")
|
||||
@@ -169,7 +163,9 @@ func TestSideUsageRecordedOnceOnConsumerCancellation(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer pg.Close()
|
||||
for _, early := range []bool{false, true} {
|
||||
// full: read to the end. cancel: cancel ctx, then stop reading.
|
||||
// abandon: stop reading before message_stop with ctx still live.
|
||||
for _, mode := range []string{"full", "cancel", "abandon"} {
|
||||
profile := "btw-metering-" + uuid.NewString()
|
||||
ctx, cancel := context.WithCancel(transcript.WithSessionID(t.Context(), "exp0-btw-test"))
|
||||
recorder := Wrap(meteredStreamProvider{}, pg, "fixture", profile, "", "", func() bool { return false })
|
||||
@@ -177,8 +173,10 @@ func TestSideUsageRecordedOnceOnConsumerCancellation(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if early && event.Type == llm.SEMessageDelta {
|
||||
cancel()
|
||||
if mode != "full" && event.Type == llm.SEMessageDelta {
|
||||
if mode == "cancel" {
|
||||
cancel()
|
||||
}
|
||||
break // Consumer exits before the provider can return a cancellation event.
|
||||
}
|
||||
}
|
||||
@@ -192,11 +190,11 @@ FROM llm_usage WHERE profile_name=$1`, profile).Scan(&count, &input, &output, &w
|
||||
t.Fatal(err)
|
||||
}
|
||||
wantStatus := "ok"
|
||||
if early {
|
||||
if mode != "full" {
|
||||
wantStatus = "error"
|
||||
}
|
||||
if count != 1 || input != 23 || output != 5 || worker != "btw" || status != wantStatus {
|
||||
t.Fatalf("early=%v: count=%d usage=%d/%d worker=%q status=%q", early, count, input, output, worker, status)
|
||||
t.Fatalf("mode=%s: count=%d usage=%d/%d worker=%q status=%q", mode, count, input, output, worker, status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ func TestChatUnavailableReasonDistinguishesStates(t *testing.T) {
|
||||
if err != nil {
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
t.Cleanup(func() { _ = m.Close() })
|
||||
td := t.TempDir()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
s := New(ctx, m, td, td, td)
|
||||
@@ -68,7 +68,7 @@ func TestResolveChatAgentHonoursConversationProfile(t *testing.T) {
|
||||
if err != nil {
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
t.Cleanup(func() { _ = m.Close() })
|
||||
td := t.TempDir()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
s := New(ctx, m, td, td, td)
|
||||
|
||||
@@ -73,6 +73,9 @@ func TestCoreTaskLifecyclePG(t *testing.T) {
|
||||
if id == "" || expID == 0 {
|
||||
t.Fatalf("bad task payload: %v", out)
|
||||
}
|
||||
defer func() {
|
||||
_, _ = m.pg.Exec(`DELETE FROM assets WHERE type = 'ip' AND ip = '127.0.0.1'`)
|
||||
}()
|
||||
|
||||
// the exploration owns goal node(s) — goal seeding is async, poll briefly
|
||||
var goals []*db.Node
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestResetSettledRunReseedsBudgetFromUsage(t *testing.T) {
|
||||
if err != nil {
|
||||
pgdb.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
t.Cleanup(func() { _ = m.Close() })
|
||||
|
||||
taskID := strconv.FormatInt(time.Now().UnixNano(), 10)
|
||||
t.Cleanup(func() {
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The record_fact texts seeded by the releases v0.4.0 to v0.6.0, copied from
|
||||
// agent/tools.go at those tags. They are kept here, apart from the agent
|
||||
// package's list of known defaults, so the test fails when that list drifts
|
||||
// from the released bytes.
|
||||
const fix410ReleasedDescription = "Write an exploration [fact/conclusion] into the exploration graph, linked to the intent that produced it (intent_id). Used to record exploration results — both [positive conclusions] like fingerprinting/enumeration, and [negative conclusions] like 'port closed'/'parameter not injectable'/'no login entry found'.\n" +
|
||||
"⚠️Multiple observations from one exploration must be [consolidated into ONE fact], not split into many; whenever they can be merged into one fact, use one: summary = a one-sentence summary of this conclusion, detail = the related details (may contain multiple concrete items). Example: a fingerprinting intent → one fact {summary:'identified the tech stack and response characteristics of site X', detail:'nginx 1.25 / Vue3 / 200 / title=.. / body_len=..'}, rather than one fact each for status code, fingerprint, and title. One intent usually produces exactly one fact; splitting too finely bloats the graph endlessly.\n" +
|
||||
"★The facts array writes several [mutually distinct] conclusions at once (each may omit intent_id, defaulting to the top-level intent_id). Returns an ids array, same length and order as facts.\n" +
|
||||
"⚠️Write only conclusions you [actually saw] in tool output — don't extrapolate. evidence and confidence keep inaccurate conclusions from polluting the graph:\n" +
|
||||
" · evidence = [one line] of key evidence supporting this conclusion (the command + the one or two most proving output lines), **keep it brief** — details belong in detail; don't paste large output blocks here.\n" +
|
||||
" · confidence = observed (seen directly in output) | inferred (inferred from phenomena).\n" +
|
||||
" · **Negative conclusions** (not injectable / port closed / no entry found, etc.) state only \"observation + tentative reading\" — state what you actually saw; whether to abandon the direction is for the planner to decide globally; always provide evidence, mark inferred when the means weren't exhausted or the evidence is weak (including probed only once, looks-like), and mark observed only when truly exhausted and directly seen."
|
||||
|
||||
const fix410ReleasedFactsDescription = "[use when there are several distinct conclusions] array of facts; element fields same as the top-level fields below (summary/detail/evidence/confidence/intent_id/asset_ids); omitting intent_id falls back to the top-level intent_id. The returned ids match this array in length and order."
|
||||
|
||||
// A database seeded by a release stores the released record_fact description,
|
||||
// the released facts property description and facts items without properties.
|
||||
// The one-time refresh replaces both texts with the current ones and sets its
|
||||
// flag; texts an operator edited match no known default and stay as stored.
|
||||
func TestFix410ReleasedDefaultsRefreshed(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
name, text, sum string
|
||||
size int
|
||||
}{
|
||||
{"description", fix410ReleasedDescription, "0da5cec5cde7f5e6f41343418fcc2a7d132d6520f336efb39fcbf1ab6ac51957", 2038},
|
||||
{"facts description", fix410ReleasedFactsDescription, "eb054843a6b33dd39b94ba0648f292babb9cf9bdd106ee4eff6bf593d3f3edf4", 286},
|
||||
} {
|
||||
sum := sha256.Sum256([]byte(c.text))
|
||||
if len(c.text) != c.size || hex.EncodeToString(sum[:]) != c.sum {
|
||||
t.Fatalf("the released %s in this test is not the released text: %d bytes, sha256 %x", c.name, len(c.text), sum)
|
||||
}
|
||||
}
|
||||
skipWithoutDSN(t)
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer m.Close()
|
||||
s := &Server{m: m}
|
||||
const flag = "tool_schema_refresh_record_fact_facts_only"
|
||||
seed := recordFactSeed(t)
|
||||
seedSchema, _ := json.Marshal(seed.Schema)
|
||||
seedAgents, _ := json.Marshal(seed.Agents)
|
||||
defer func() {
|
||||
_ = m.pg.UpsertToolForce("record_fact", seed.Desc, seedSchema, seedAgents)
|
||||
_, _ = m.pg.Exec(`DELETE FROM settings WHERE key=$1`, flag)
|
||||
}()
|
||||
currentFacts := seed.Schema["properties"].(map[string]any)["facts"].(map[string]any)["description"]
|
||||
|
||||
// start stores the row as a release seeded it, with the given two texts,
|
||||
// runs the startup steps and returns the two texts as stored afterwards.
|
||||
start := func(desc, factsDesc string) (string, any) {
|
||||
t.Helper()
|
||||
str := func(d string) map[string]any { return map[string]any{"type": "string", "description": d} }
|
||||
schema, _ := json.Marshal(map[string]any{"type": "object", "properties": map[string]any{
|
||||
"facts": map[string]any{"type": "array", "description": factsDesc, "items": map[string]any{"type": "object"}},
|
||||
"summary": str("a [one-sentence summary] of this exploration's conclusion (a condensation of detail)"),
|
||||
"intent_id": map[string]any{"type": "integer", "description": "the id of the intent that produced this fact (the intent you claimed; the default for each item in batch mode)"},
|
||||
"detail": str("details related to this fact: write all of this exploration's observations here"),
|
||||
"evidence": str("[one line] of key evidence: the command + the one or two most proving output lines. Keep it brief; don't paste large output blocks (details go in detail)."),
|
||||
"confidence": str("observed (seen directly in output) | inferred (inferred from phenomena). Always label negative conclusions honestly."),
|
||||
"asset_ids": map[string]any{"type": "array", "items": map[string]any{"type": "integer"}, "description": "related asset ids (optional, 0/1/many): which assets this fact involves"},
|
||||
}})
|
||||
if err := m.pg.UpsertToolForce("record_fact", desc, schema, seedAgents); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := m.pg.Exec(`DELETE FROM settings WHERE key=$1`, flag); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.seedFactInputSchema()
|
||||
s.seedFactSourceSchema()
|
||||
s.refreshRecordFactContract()
|
||||
if v, _, _ := m.pg.GetSetting(flag); v != "true" {
|
||||
t.Errorf("flag = %q after the refresh, want true", v)
|
||||
}
|
||||
row, err := m.pg.GetTool("record_fact")
|
||||
if err != nil || row == nil {
|
||||
t.Fatalf("row: %v", err)
|
||||
}
|
||||
var stored struct {
|
||||
Properties map[string]map[string]any `json:"properties"`
|
||||
}
|
||||
if err := json.Unmarshal(row.Schema, &stored); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(stored.Properties) != 1 || stored.Properties["facts"] == nil {
|
||||
t.Fatalf("top level still holds fact fields: %s", row.Schema)
|
||||
}
|
||||
return row.Description, stored.Properties["facts"]["description"]
|
||||
}
|
||||
|
||||
desc, factsDesc := start(fix410ReleasedDescription, fix410ReleasedFactsDescription)
|
||||
if desc != seed.Desc {
|
||||
t.Errorf("released description not replaced by the current one: %.60q", desc)
|
||||
}
|
||||
if factsDesc != currentFacts {
|
||||
t.Errorf("released facts description not replaced by the current one: %v", factsDesc)
|
||||
}
|
||||
|
||||
editedDesc := fix410ReleasedDescription + "\nOperator note: record every negative result."
|
||||
editedFacts := fix410ReleasedFactsDescription + " Operator note: one fact per host."
|
||||
desc, factsDesc = start(editedDesc, editedFacts)
|
||||
if desc != editedDesc {
|
||||
t.Errorf("operator description changed: %.60q", desc)
|
||||
}
|
||||
if factsDesc != editedFacts {
|
||||
t.Errorf("operator facts description changed: %v", factsDesc)
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,99 @@ import (
|
||||
|
||||
// SeedTool only inserts new rows. Repair existing built-ins too, while keeping
|
||||
// descriptions, bindings, enabled/deferred flags and parameter annotations.
|
||||
|
||||
// refreshRecordFactContract brings an already-seeded record_fact row to the
|
||||
// facts-only contract (one-time, settings flag). SeedTool is first-insert-only
|
||||
// and ToolResolve serves the stored text, so without this an old database keeps
|
||||
// describing the earlier contract (fact fields at the top level beside facts[])
|
||||
// to the model. Only text equal to the previous code default is replaced:
|
||||
// - the tool description;
|
||||
// - the facts property and item descriptions that referred to the top level.
|
||||
//
|
||||
// Operator edits stay; a description that matches no known default is logged
|
||||
// as such and left in place. The schema structure itself is repaired by
|
||||
// seedFactInputSchema on every start (RepairRecordFactSchema).
|
||||
//
|
||||
// The flag is written only once the outcome is known: the UPDATE succeeded
|
||||
// (also when it changed no row) or the row is not the built-in one. A failed
|
||||
// read, decode or UPDATE leaves it unset, so the next start retries.
|
||||
func (s *Server) refreshRecordFactContract() {
|
||||
const flag = "tool_schema_refresh_record_fact_facts_only"
|
||||
if v, _, _ := s.m.pg.GetSetting(flag); v == "true" {
|
||||
return
|
||||
}
|
||||
done := func() { _ = s.m.pg.SetSetting(flag, "true") }
|
||||
var seed *agent.ToolSeed
|
||||
for _, sd := range agent.BuiltinToolSeeds() {
|
||||
if sd.Key == "record_fact" {
|
||||
seed = &sd
|
||||
break
|
||||
}
|
||||
}
|
||||
row, err := s.m.pg.GetTool("record_fact")
|
||||
if err != nil {
|
||||
log.Printf("[facts] read record_fact for the contract refresh: %v", err)
|
||||
return
|
||||
}
|
||||
if row == nil || seed == nil {
|
||||
return
|
||||
}
|
||||
if !row.System || row.Kind != "builtin" {
|
||||
done()
|
||||
return
|
||||
}
|
||||
legacyTool, legacyFacts, legacyItems := agent.RecordFactLegacyDescriptions()
|
||||
desc := row.Description
|
||||
switch {
|
||||
case desc == seed.Desc:
|
||||
case sliceHas(legacyTool, desc):
|
||||
desc = seed.Desc
|
||||
default:
|
||||
log.Printf("[facts] record_fact description does not match a known default (operator edit or an older release); the facts-only schema is published anyway, review the text in the tool catalog")
|
||||
}
|
||||
var schema map[string]any
|
||||
if err := json.Unmarshal(row.Schema, &schema); err != nil {
|
||||
log.Printf("[facts] decode record_fact schema: %v", err)
|
||||
return
|
||||
}
|
||||
repaired := agent.RepairRecordFactSchema(schema)
|
||||
facts := repaired["properties"].(map[string]any)["facts"].(map[string]any)
|
||||
canonFacts := seed.Schema["properties"].(map[string]any)["facts"].(map[string]any)
|
||||
if d, ok := facts["description"].(string); ok && sliceHas(legacyFacts, d) {
|
||||
facts["description"] = canonFacts["description"]
|
||||
}
|
||||
items := facts["items"].(map[string]any)["properties"].(map[string]any)
|
||||
canonItems := canonFacts["items"].(map[string]any)["properties"].(map[string]any)
|
||||
for name, old := range legacyItems {
|
||||
prop, _ := items[name].(map[string]any)
|
||||
want, _ := canonItems[name].(map[string]any)
|
||||
if prop != nil && want != nil && prop["description"] == old {
|
||||
prop["description"] = want["description"]
|
||||
}
|
||||
}
|
||||
raw, err := json.Marshal(repaired)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if _, err := s.m.pg.Exec(`UPDATE tools SET description=$1, schema=$2::jsonb, updated_at=now()
|
||||
WHERE key='record_fact' AND system AND kind='builtin'
|
||||
AND (description IS DISTINCT FROM $1 OR schema IS DISTINCT FROM $2::jsonb)`, desc, string(raw)); err != nil {
|
||||
log.Printf("[facts] refresh record_fact contract: %v", err)
|
||||
return
|
||||
}
|
||||
done()
|
||||
log.Printf("[facts] record_fact now publishes the facts-only contract (one-time)")
|
||||
}
|
||||
|
||||
func sliceHas(list []string, s string) bool {
|
||||
for _, v := range list {
|
||||
if v == s {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *Server) seedFactInputSchema() {
|
||||
row, err := s.m.pg.GetTool("record_fact")
|
||||
if err != nil {
|
||||
|
||||
@@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -42,10 +43,16 @@ func TestRecordFactInputSchemaUpgrade(t *testing.T) {
|
||||
if err := pg.UpdateTool("record_fact", "operator tool", raw, bindings, old.Enabled); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Facts-only contract: the top level holds facts and
|
||||
// nothing else; the earlier top-level fact fields and their operator
|
||||
// annotations are dropped (the handler still accepts the legacy shapes),
|
||||
// item annotations survive.
|
||||
check := func(schema map[string]any) {
|
||||
t.Helper()
|
||||
if _, ok := schema["required"]; ok {
|
||||
t.Fatal("top-level summary still required for batches")
|
||||
if req, _ := schema["required"].([]any); len(req) != 1 || req[0] != "facts" {
|
||||
if reqS, _ := schema["required"].([]string); len(reqS) != 1 || reqS[0] != "facts" {
|
||||
t.Fatalf("facts must be the only required property: %v", schema["required"])
|
||||
}
|
||||
}
|
||||
if _, ok := schema["anyOf"]; ok {
|
||||
t.Fatal("root anyOf still present")
|
||||
@@ -54,14 +61,13 @@ func TestRecordFactInputSchemaUpgrade(t *testing.T) {
|
||||
t.Fatal("unknown fields allowed")
|
||||
}
|
||||
props := schema["properties"].(map[string]any)
|
||||
if len(props) != 1 || props["facts"] == nil {
|
||||
t.Fatalf("top level must hold facts only: %v", props)
|
||||
}
|
||||
items := props["facts"].(map[string]any)["items"].(map[string]any)
|
||||
itemProps := items["properties"].(map[string]any)
|
||||
if props["tested_asset_ids"] == nil || itemProps["tested_asset_ids"] == nil || itemProps["summary"] == nil {
|
||||
t.Fatal("repaired schema missing alias or batch summary")
|
||||
}
|
||||
if props["summary"].(map[string]any)["description"] != "operator summary" ||
|
||||
props["confidence"].(map[string]any)["default"] != "inferred" || props["custom"] != nil {
|
||||
t.Fatal("operator annotations lost")
|
||||
if itemProps["tested_asset_ids"] == nil || itemProps["summary"] == nil || itemProps["source"] == nil {
|
||||
t.Fatal("repaired schema missing alias, batch summary or source")
|
||||
}
|
||||
if err := actool.ValidateInput(schema, json.RawMessage(`{"facts":[{"summary":"complete batch item"}]}`)); err != nil {
|
||||
t.Fatal("valid batch rejected", err)
|
||||
@@ -104,3 +110,217 @@ func TestRecordFactInputSchemaUpgrade(t *testing.T) {
|
||||
t.Fatal("second migration changed the row")
|
||||
}
|
||||
}
|
||||
|
||||
// recordFactLegacySchema is the stored record_fact schema of the earlier
|
||||
// contract: fact fields at the top level beside facts[], with the texts that
|
||||
// referred to the top level, plus an operator annotation on an item field.
|
||||
func recordFactLegacySchema(t *testing.T) (string, map[string]string) {
|
||||
t.Helper()
|
||||
_, legacyFacts, legacyItems := agent.RecordFactLegacyDescriptions()
|
||||
item := map[string]any{"type": "object", "required": []string{"summary"}, "additionalProperties": false, "properties": map[string]any{
|
||||
"summary": map[string]any{"type": "string", "minLength": 1, "description": legacyItems["summary"]},
|
||||
"intent_id": map[string]any{"type": "integer", "description": legacyItems["intent_id"]},
|
||||
"detail": map[string]any{"type": "string", "description": "Details of this fact, including all related observations."},
|
||||
"confidence": map[string]any{"type": "string", "description": "operator confidence note", "default": "inferred"},
|
||||
"source": map[string]any{"type": "string", "enum": []string{"target_response", "tool_output", "third_party_intel", "operator_input", "inference"}, "description": "where the content came from"},
|
||||
}}
|
||||
schema := map[string]any{"type": "object", "additionalProperties": false, "properties": map[string]any{
|
||||
"summary": map[string]any{"type": "string", "minLength": 1, "description": legacyItems["summary"]},
|
||||
"intent_id": map[string]any{"type": "integer", "description": legacyItems["intent_id"]},
|
||||
"detail": map[string]any{"type": "string", "description": "Details of this fact, including all related observations."},
|
||||
"source": map[string]any{"type": "string", "enum": []string{"inference"}},
|
||||
"facts": map[string]any{"type": "array", "minItems": 1, "description": legacyFacts[0], "items": item},
|
||||
}}
|
||||
raw, _ := json.Marshal(schema)
|
||||
return string(raw), legacyItems
|
||||
}
|
||||
|
||||
func recordFactSeed(t *testing.T) agent.ToolSeed {
|
||||
t.Helper()
|
||||
for _, sd := range agent.BuiltinToolSeeds() {
|
||||
if sd.Key == "record_fact" {
|
||||
return sd
|
||||
}
|
||||
}
|
||||
t.Fatal("record_fact seed missing")
|
||||
return agent.ToolSeed{}
|
||||
}
|
||||
|
||||
// A database that still stores the earlier record_fact contract (text and
|
||||
// schema) is brought to the facts-only contract once: description replaced
|
||||
// when it is the previous default, facts/item descriptions replaced when they
|
||||
// are the earlier texts, operator annotations kept, top-level fact fields
|
||||
// gone, source enum present on the items. A second run changes nothing, and
|
||||
// an operator-edited description is left alone.
|
||||
func TestRefreshRecordFactContract(t *testing.T) {
|
||||
skipWithoutDSN(t)
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
}
|
||||
defer m.Close()
|
||||
s := &Server{m: m}
|
||||
seed := recordFactSeed(t)
|
||||
seedSchema, _ := json.Marshal(seed.Schema)
|
||||
seedAgents, _ := json.Marshal(seed.Agents)
|
||||
restore := func() {
|
||||
_ = m.pg.UpsertToolForce("record_fact", seed.Desc, seedSchema, seedAgents)
|
||||
_, _ = m.pg.Exec(`DELETE FROM settings WHERE key='tool_schema_refresh_record_fact_facts_only'`)
|
||||
}
|
||||
defer restore()
|
||||
|
||||
legacyTool, _, legacyItems := agent.RecordFactLegacyDescriptions()
|
||||
legacySchema, _ := recordFactLegacySchema(t)
|
||||
run := func(desc string) {
|
||||
t.Helper()
|
||||
if err := m.pg.UpsertToolForce("record_fact", desc, json.RawMessage(legacySchema), seedAgents); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := m.pg.Exec(`DELETE FROM settings WHERE key='tool_schema_refresh_record_fact_facts_only'`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.seedFactInputSchema()
|
||||
s.seedFactSourceSchema()
|
||||
s.refreshRecordFactContract()
|
||||
}
|
||||
for _, desc := range legacyTool {
|
||||
run(desc)
|
||||
row, err := m.pg.GetTool("record_fact")
|
||||
if err != nil || row == nil {
|
||||
t.Fatalf("row: %v", err)
|
||||
}
|
||||
if row.Description != seed.Desc {
|
||||
t.Fatalf("description not refreshed from a known default: %q", row.Description[:60])
|
||||
}
|
||||
var schema map[string]any
|
||||
if err := json.Unmarshal(row.Schema, &schema); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
props := schema["properties"].(map[string]any)
|
||||
if len(props) != 1 || props["facts"] == nil {
|
||||
t.Fatalf("top level still holds fact fields: %v", props)
|
||||
}
|
||||
facts := props["facts"].(map[string]any)
|
||||
items := facts["items"].(map[string]any)["properties"].(map[string]any)
|
||||
canonItems := seed.Schema["properties"].(map[string]any)["facts"].(map[string]any)["items"].(map[string]any)["properties"].(map[string]any)
|
||||
if facts["description"] != seed.Schema["properties"].(map[string]any)["facts"].(map[string]any)["description"] {
|
||||
t.Fatalf("facts description not refreshed: %v", facts["description"])
|
||||
}
|
||||
for name := range legacyItems {
|
||||
if items[name].(map[string]any)["description"] != canonItems[name].(map[string]any)["description"] {
|
||||
t.Fatalf("item %s description not refreshed: %v", name, items[name])
|
||||
}
|
||||
}
|
||||
if items["confidence"].(map[string]any)["description"] != "operator confidence note" || items["confidence"].(map[string]any)["default"] != "inferred" {
|
||||
t.Fatalf("operator annotation lost: %v", items["confidence"])
|
||||
}
|
||||
if enum, _ := items["source"].(map[string]any)["enum"].([]any); len(enum) != 5 {
|
||||
t.Fatalf("source enum missing on the items: %v", items["source"])
|
||||
}
|
||||
if v, _, _ := m.pg.GetSetting("tool_schema_refresh_record_fact_facts_only"); v != "true" {
|
||||
t.Fatal("flag not set")
|
||||
}
|
||||
// Second start: nothing changes.
|
||||
var updated1, updated2 string
|
||||
_ = m.pg.QueryRow(`SELECT updated_at::text FROM tools WHERE key='record_fact'`).Scan(&updated1)
|
||||
s.seedFactInputSchema()
|
||||
s.seedFactSourceSchema()
|
||||
s.refreshRecordFactContract()
|
||||
_ = m.pg.QueryRow(`SELECT updated_at::text FROM tools WHERE key='record_fact'`).Scan(&updated2)
|
||||
if updated1 != updated2 {
|
||||
t.Fatal("second start rewrote the row")
|
||||
}
|
||||
}
|
||||
// An operator-edited description is kept; the schema is still repaired.
|
||||
run("my own record_fact text")
|
||||
row, _ := m.pg.GetTool("record_fact")
|
||||
if row == nil || row.Description != "my own record_fact text" {
|
||||
t.Fatalf("operator description replaced: %v", row)
|
||||
}
|
||||
if !strings.Contains(string(row.Schema), `"facts"`) || strings.Contains(string(row.Schema), legacyItems["intent_id"]) {
|
||||
t.Fatalf("schema not repaired beside an operator description: %s", row.Schema)
|
||||
}
|
||||
}
|
||||
|
||||
// A start on which the refresh fails must not spend the one-time flag: the
|
||||
// next start retries and the stored default text is refreshed then.
|
||||
func TestFix410RefreshFlagNotSetOnFailure(t *testing.T) {
|
||||
skipWithoutDSN(t)
|
||||
m, err := NewManager(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Skipf("postgres unavailable (%v)", err)
|
||||
}
|
||||
defer m.Close()
|
||||
s := &Server{m: m}
|
||||
const flag = "tool_schema_refresh_record_fact_facts_only"
|
||||
seed := recordFactSeed(t)
|
||||
seedSchema, _ := json.Marshal(seed.Schema)
|
||||
seedAgents, _ := json.Marshal(seed.Agents)
|
||||
legacyTool, _, _ := agent.RecordFactLegacyDescriptions()
|
||||
legacySchema, _ := recordFactLegacySchema(t)
|
||||
exec := func(query string, args ...any) {
|
||||
t.Helper()
|
||||
if _, err := m.pg.Exec(query, args...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
const dropTrigger = `DROP TRIGGER IF EXISTS fix410_fail_update ON tools`
|
||||
defer func() {
|
||||
_, _ = m.pg.Exec(dropTrigger)
|
||||
_, _ = m.pg.Exec(`DROP FUNCTION IF EXISTS fix410_fail_update()`)
|
||||
_ = m.pg.UpsertToolForce("record_fact", seed.Desc, seedSchema, seedAgents)
|
||||
_, _ = m.pg.Exec(`DELETE FROM settings WHERE key=$1`, flag)
|
||||
}()
|
||||
exec(`CREATE OR REPLACE FUNCTION fix410_fail_update() RETURNS trigger LANGUAGE plpgsql AS
|
||||
'BEGIN RAISE EXCEPTION ''fix410: simulated transient failure''; END'`)
|
||||
|
||||
start := func() {
|
||||
s.seedFactInputSchema()
|
||||
s.seedFactSourceSchema()
|
||||
s.refreshRecordFactContract()
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
fail, clear func()
|
||||
}{
|
||||
{"update fails", func() {
|
||||
exec(`CREATE TRIGGER fix410_fail_update BEFORE UPDATE ON tools
|
||||
FOR EACH ROW WHEN (OLD.key = 'record_fact') EXECUTE FUNCTION fix410_fail_update()`)
|
||||
}, func() { exec(dropTrigger) }},
|
||||
{"schema does not decode", func() {
|
||||
exec(`UPDATE tools SET schema='[]'::jsonb WHERE key='record_fact'`)
|
||||
}, func() {
|
||||
exec(`UPDATE tools SET schema=$1::jsonb WHERE key='record_fact'`, legacySchema)
|
||||
}},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
// A database that stores the earlier default text and has not run the refresh.
|
||||
if err := m.pg.UpsertToolForce("record_fact", legacyTool[0], json.RawMessage(legacySchema), seedAgents); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
exec(`DELETE FROM settings WHERE key=$1`, flag)
|
||||
|
||||
tc.fail()
|
||||
start()
|
||||
if v, ok, _ := m.pg.GetSetting(flag); ok {
|
||||
t.Errorf("flag is %q after a failed refresh: later starts skip it", v)
|
||||
}
|
||||
if row, _ := m.pg.GetTool("record_fact"); row == nil || row.Description != legacyTool[0] {
|
||||
t.Fatal("the simulated failure did not leave the earlier description in place")
|
||||
}
|
||||
|
||||
tc.clear()
|
||||
start()
|
||||
row, err := m.pg.GetTool("record_fact")
|
||||
if err != nil || row == nil {
|
||||
t.Fatalf("row: %v", err)
|
||||
}
|
||||
if row.Description != seed.Desc {
|
||||
t.Errorf("the next start did not refresh the description: %.60q", row.Description)
|
||||
}
|
||||
if v, _, _ := m.pg.GetSetting(flag); v != "true" {
|
||||
t.Errorf("flag = %q after a successful refresh, want true", v)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,12 +35,13 @@ func TestRecordFactSourceSchemaUpgrade(t *testing.T) {
|
||||
t.Cleanup(func() { pg.UpdateTool(old.Key, old.Description, old.Schema, bindings, old.Enabled) })
|
||||
|
||||
// Simulate a pre-provenance row customised by the operator: no source
|
||||
// property, an edited description and an edited parameter description.
|
||||
// property on the facts items, an edited description and an edited
|
||||
// parameter description (facts-only contract: the items carry the fields).
|
||||
var schema map[string]any
|
||||
if err := json.Unmarshal(old.Schema, &schema); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
props := schema["properties"].(map[string]any)
|
||||
props := schema["properties"].(map[string]any)["facts"].(map[string]any)["items"].(map[string]any)["properties"].(map[string]any)
|
||||
delete(props, "source")
|
||||
props["confidence"].(map[string]any)["description"] = "operator confidence text"
|
||||
custom, _ := json.Marshal(schema)
|
||||
@@ -72,16 +73,23 @@ func TestRecordFactSourceSchemaUpgrade(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var got struct {
|
||||
Properties map[string]map[string]any `json:"properties"`
|
||||
Properties struct {
|
||||
Facts struct {
|
||||
Items struct {
|
||||
Properties map[string]map[string]any `json:"properties"`
|
||||
} `json:"items"`
|
||||
} `json:"facts"`
|
||||
} `json:"properties"`
|
||||
}
|
||||
if err := json.Unmarshal(tool.Schema, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
itemProps := got.Properties.Facts.Items.Properties
|
||||
wantEnum := "[target_response tool_output third_party_intel operator_input inference]"
|
||||
if src := got.Properties["source"]; src == nil || fmt.Sprint(src["enum"]) != wantEnum {
|
||||
if src := itemProps["source"]; src == nil || fmt.Sprint(src["enum"]) != wantEnum {
|
||||
t.Fatalf("upgrade did not add the source enum: %s", tool.Schema)
|
||||
}
|
||||
if tool.Description != "operator description" || got.Properties["confidence"]["description"] != "operator confidence text" || len(got.Properties) != len(props)+1 {
|
||||
if tool.Description != "operator description" || itemProps["confidence"]["description"] != "operator confidence text" || len(itemProps) != len(props)+1 {
|
||||
t.Fatalf("operator configuration overwritten: %q %s", tool.Description, tool.Schema)
|
||||
}
|
||||
|
||||
@@ -92,15 +100,18 @@ func TestRecordFactSourceSchemaUpgrade(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// resolvedRecordFactProps returns the properties of record_fact as ToolResolve
|
||||
// serves it to the worker.
|
||||
// resolvedRecordFactProps returns the facts[] item properties of record_fact as
|
||||
// ToolResolve serves it to the worker.
|
||||
func resolvedRecordFactProps(t *testing.T) map[string]any {
|
||||
t.Helper()
|
||||
tools := agent.ToolResolve()(context.Background(), "worker", agent.NewToolSet(nil, "").WorkerTools())
|
||||
for _, tl := range tools {
|
||||
if tl.Name() == "record_fact" {
|
||||
props, _ := tl.InputSchema()["properties"].(map[string]any)
|
||||
return props
|
||||
facts, _ := props["facts"].(map[string]any)
|
||||
items, _ := facts["items"].(map[string]any)
|
||||
itemProps, _ := items["properties"].(map[string]any)
|
||||
return itemProps
|
||||
}
|
||||
}
|
||||
t.Fatal("worker lost record_fact")
|
||||
|
||||
@@ -38,7 +38,11 @@ func trafficEvidenceServer(t *testing.T) (*Server, *db.RecordedFinding, func(str
|
||||
t.Fatal(err)
|
||||
}
|
||||
tid, _ := strconv.ParseInt(task.ID, 10, 64)
|
||||
t.Cleanup(func() { m.pg.Exec(`DELETE FROM task_archives WHERE task_id=$1`, tid); m.pg.DeleteTask(tid) })
|
||||
t.Cleanup(func() {
|
||||
_, _ = m.pg.DeleteFindingsByTask(tid)
|
||||
_, _ = m.pg.Exec(`DELETE FROM task_archives WHERE task_id=$1`, tid)
|
||||
_ = m.pg.DeleteTask(tid)
|
||||
})
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
s := New(ctx, m, t.TempDir(), t.TempDir(), t.TempDir())
|
||||
@@ -278,6 +282,7 @@ func TestFindingTrafficArchiveV3RoundTripAndRetry(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer s.m.pg.DeleteFinding(shared.FindingID)
|
||||
if _, err = s.m.traffic.DeleteHost("evidence.local"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -286,15 +286,19 @@ func TestDeepenAdmissionFailureDiscardsFollowUpIntent(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
taskID, _ := strconv.ParseInt(task.ID, 10, 64)
|
||||
var findingID int64
|
||||
defer func() {
|
||||
_, _ = m.pg.Exec(`UPDATE tasks SET deleted_at=NULL WHERE id=$1`, taskID)
|
||||
if findingID > 0 {
|
||||
_, _ = m.pg.DeleteFinding(findingID)
|
||||
}
|
||||
_, _ = m.DeleteTask(task.ID, DeleteTaskOptions{})
|
||||
}()
|
||||
findingNodeID, err := task.Store.AddNode(db.KindFinding, map[string]any{"summary": "source"}, 5, "confirmed", "worker", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
findingID, err := m.pg.AddFinding(taskID, findingNodeID, "test", "source", db.SeverityHigh, "source", "", "worker", nil)
|
||||
findingID, err = m.pg.AddFinding(taskID, findingNodeID, "test", "source", db.SeverityHigh, "source", "", "worker", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,10 @@ func TestTaskLessonsExtractionAndIdempotency(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
taskID, _ := strconv.ParseInt(task.ID, 10, 64)
|
||||
defer func() { _ = m.pg.DeleteTask(taskID) }()
|
||||
defer func() {
|
||||
_, _ = m.pg.DeleteFindingsByTask(taskID)
|
||||
_ = m.pg.DeleteTask(taskID)
|
||||
}()
|
||||
defer func() { _, _ = m.pg.Exec(`DELETE FROM rsi_lessons`) }()
|
||||
|
||||
if _, err := m.pg.Exec(`
|
||||
@@ -138,7 +141,10 @@ func TestTerminalStatusExtractsLessons(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
taskID, _ := strconv.ParseInt(task.ID, 10, 64)
|
||||
defer func() { _ = m.pg.DeleteTask(taskID) }()
|
||||
defer func() {
|
||||
_, _ = m.pg.DeleteFindingsByTask(taskID)
|
||||
_ = m.pg.DeleteTask(taskID)
|
||||
}()
|
||||
if _, err := m.pg.Exec(`
|
||||
INSERT INTO findings(task_id,vulnclass,name,summary,severity,status)
|
||||
VALUES ($1,'xss','Reflected XSS','reflected in search','high','confirmed')`, taskID); err != nil {
|
||||
|
||||
@@ -74,6 +74,7 @@ func TestRecorderPersistsRawWireBodies(t *testing.T) {
|
||||
if _, err := pg.Exec(`DELETE FROM llm_records WHERE session_id = $1`, session); err != nil {
|
||||
t.Logf("cleanup: %v", err)
|
||||
}
|
||||
_, _ = pg.Exec(`DELETE FROM llm_usage WHERE task_id = '999999' AND profile_name = 'raw-test-profile'`)
|
||||
}()
|
||||
|
||||
ctx := transcript.WithSessionID(context.Background(), session)
|
||||
|
||||
@@ -18,7 +18,7 @@ func TestSeedAssociatesTargetAssetWithTask(t *testing.T) {
|
||||
if err != nil {
|
||||
pgdb.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
t.Cleanup(func() { _ = m.Close() })
|
||||
task, err := m.CreateTask("seed ownership", "seed ownership", nil, 0, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -72,7 +72,10 @@ func newNotifyFixture(t *testing.T) *notifyFixture {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { pg.Exec(`DELETE FROM tasks WHERE id=$1`, taskID) })
|
||||
t.Cleanup(func() {
|
||||
_, _ = pg.DeleteFindingsByTask(taskID)
|
||||
_ = pg.DeleteTask(taskID)
|
||||
})
|
||||
|
||||
var mark int64
|
||||
if err := pg.QueryRow(`SELECT COALESCE(max(id),0) FROM notification_events`).Scan(&mark); err != nil {
|
||||
|
||||
+16
-3
@@ -573,6 +573,7 @@ func (s *Server) seedOrchestrationTools() {
|
||||
s.seedFindingEvidenceSchema() // optional counterevidence / confidence_rationale on report_finding, added once per DB
|
||||
s.seedFactInputSchema() // restore record_fact single/batch contracts
|
||||
s.seedFactSourceSchema() // source enum on record_fact, added once per DB
|
||||
s.refreshRecordFactContract() // record_fact publishes the facts-only contract (one-time)
|
||||
s.seedTaskScopeDescription() // add_task_scope: "coverage scope, not enforced" replaces the authorization-boundary text
|
||||
// Note: pentest's default tool bindings need no migration — BuiltinToolSeeds already seeds
|
||||
// list_assets/insert_assets/report_finding/list_findings/list_companies together with
|
||||
@@ -602,11 +603,23 @@ func (s *Server) seedFactSourceSchema() {
|
||||
if err := json.Unmarshal(obj["properties"], &properties); err != nil {
|
||||
return
|
||||
}
|
||||
if len(properties["source"]) == 0 {
|
||||
// The source enum lives on the facts[] items (facts-only contract); the
|
||||
// top level has no fact fields any more.
|
||||
var facts map[string]json.RawMessage
|
||||
var items map[string]json.RawMessage
|
||||
var itemProps map[string]json.RawMessage
|
||||
if err := json.Unmarshal(properties["facts"], &facts); err != nil {
|
||||
return
|
||||
}
|
||||
_, err = s.m.pg.Exec(`UPDATE tools SET schema=jsonb_set(schema,ARRAY['properties','source'],$1::jsonb,true),updated_at=now()
|
||||
WHERE key='record_fact' AND system AND NOT(COALESCE(schema->'properties','{}'::jsonb) ? 'source')`, string(properties["source"]))
|
||||
if err := json.Unmarshal(facts["items"], &items); err != nil {
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal(items["properties"], &itemProps); err != nil || len(itemProps["source"]) == 0 {
|
||||
return
|
||||
}
|
||||
_, err = s.m.pg.Exec(`UPDATE tools SET schema=jsonb_set(schema,ARRAY['properties','facts','items','properties','source'],$1::jsonb,true),updated_at=now()
|
||||
WHERE key='record_fact' AND system AND (schema->'properties'->'facts'->'items') ? 'properties'
|
||||
AND NOT(COALESCE(schema->'properties'->'facts'->'items'->'properties','{}'::jsonb) ? 'source')`, string(itemProps["source"]))
|
||||
if err != nil {
|
||||
log.Printf("[facts] upgrade record_fact.source: %v", err)
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ func TestPlannerQuietSkipEdge(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _, _ = m.DeleteTask(created.ID, DeleteTaskOptions{}) })
|
||||
tt, ok := m.Task(created.ID)
|
||||
if !ok {
|
||||
t.Fatal("task not found after creation")
|
||||
@@ -93,6 +94,7 @@ func TestPlannerQuietModeToggleMidRun(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _, _ = m.DeleteTask(created.ID, DeleteTaskOptions{}) })
|
||||
tt, ok := m.Task(created.ID)
|
||||
if !ok {
|
||||
t.Fatal("task not found")
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Autumn-27/norma/harness"
|
||||
"github.com/Autumn-27/norma/llm"
|
||||
actool "github.com/Autumn-27/norma/tool"
|
||||
|
||||
"github.com/Autumn-27/artex/agent"
|
||||
"github.com/Autumn-27/artex/db"
|
||||
)
|
||||
|
||||
// acceptsRawInput is the assertion norma's harness makes before its schema
|
||||
// check: only a tool that reports AcceptsRawInput skips it.
|
||||
func acceptsRawInput(t actool.CoreTool) bool {
|
||||
r, ok := t.(interface{ AcceptsRawInput() bool })
|
||||
return ok && r.AcceptsRawInput()
|
||||
}
|
||||
|
||||
// record_fact opts out of the harness schema check and validates its own
|
||||
// input. Every wrapper between the handler and the harness has to forward
|
||||
// that opt-out: an embedded CoreTool alone hides it from the harness's type
|
||||
// assertion, and the stricter published schema then rejects the calls the
|
||||
// handler exists to answer.
|
||||
func TestFix410AcceptsRawInputSurvivesWrappers(t *testing.T) {
|
||||
oldAugment, oldResolve := agent.ToolAugment(), agent.ToolResolve()
|
||||
t.Cleanup(func() {
|
||||
agent.SetToolAugment(oldAugment)
|
||||
agent.SetToolResolve(oldResolve)
|
||||
})
|
||||
ctx := context.Background()
|
||||
probe := func(raw bool) actool.CoreTool {
|
||||
return actool.Build(actool.Spec{Name: "fix410_probe", Schema: map[string]any{"type": "object"}, RawInput: raw})
|
||||
}
|
||||
|
||||
// AugmentTools without hooks applies guardPanic and nothing else.
|
||||
t.Run("guardedTool", func(t *testing.T) {
|
||||
agent.SetToolAugment(nil)
|
||||
agent.SetToolResolve(nil)
|
||||
for _, raw := range []bool{true, false} {
|
||||
out, _, cleanup := agent.AugmentTools(ctx, "worker", []actool.CoreTool{probe(raw)})
|
||||
cleanup()
|
||||
if len(out) != 1 {
|
||||
t.Fatalf("AugmentTools returned %d tools, want 1", len(out))
|
||||
}
|
||||
if got := acceptsRawInput(out[0]); got != raw {
|
||||
t.Errorf("%T: AcceptsRawInput = %v, wrapped tool reports %v", out[0], got, raw)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("meteredTool", func(t *testing.T) {
|
||||
for _, raw := range []bool{true, false} {
|
||||
wrapped := meterTool(probe(raw), &recordingToolUsage{}, "fix410_probe", "worker", agent.RunInfo{})
|
||||
if got := acceptsRawInput(wrapped); got != raw {
|
||||
t.Errorf("%T: AcceptsRawInput = %v, wrapped tool reports %v", wrapped, got, raw)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// The chain a worker's record_fact goes through on the server: the catalog
|
||||
// decorator and the usage meter (ToolResolve, wireTools), then guardPanic
|
||||
// (AugmentTools), then the harness itself.
|
||||
t.Run("server chain", func(t *testing.T) {
|
||||
dsn, _, err := db.DSN()
|
||||
if err != nil {
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
pg, err := db.Open(dsn)
|
||||
if err != nil {
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
t.Cleanup(func() { _ = pg.Close() })
|
||||
agent.SetToolAugment(nil)
|
||||
wireTools(pg, nil)
|
||||
task, err := pg.CreateTaskWithOptions("fix410", "record_fact through the wrapper chain", db.TaskCreateOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = pg.DeleteTask(task.ID) })
|
||||
ts := agent.NewToolSet(pg.Exploration(task.ExplorationID), "worker")
|
||||
tools, _, cleanup := agent.AugmentTools(ctx, "worker", ts.WorkerTools())
|
||||
defer cleanup()
|
||||
recordFact := names(tools)["record_fact"]
|
||||
if recordFact == nil {
|
||||
t.Fatal("worker has no record_fact")
|
||||
}
|
||||
if !acceptsRawInput(recordFact) {
|
||||
t.Errorf("record_fact lost the harness opt-out behind %T", recordFact)
|
||||
}
|
||||
|
||||
// The first call is malformed (facts is not an array): the harness
|
||||
// schema check answers it with its generic error unless the tool opted
|
||||
// out. The second is the legacy single fact, which the published
|
||||
// schema does not describe and the handler still accepts.
|
||||
p := &toolScript{results: make(chan string, 4), calls: []scriptedCall{
|
||||
{"record_fact", `{"facts":{"summary":"not an array"}}`},
|
||||
{"record_fact", `{"summary":"legacy single fact"}`},
|
||||
}}
|
||||
for _, err := range harness.Query(ctx, harness.QueryInput{
|
||||
Provider: p,
|
||||
Tools: actool.NewRegistry(recordFact),
|
||||
Messages: []llm.Message{llm.UserText("record the facts")},
|
||||
}, harness.QueryDeps{}) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if refusal := p.next(t); !strings.Contains(refusal, "invalid record_fact input: facts must be an array") {
|
||||
t.Errorf("malformed call: want the handler's own refusal, not the SDK schema error, got: %s", refusal)
|
||||
}
|
||||
if legacy := p.next(t); strings.HasPrefix(legacy, "[error]") || ts.Writes().Facts != 1 {
|
||||
t.Errorf("legacy single fact not written (facts=%d): %s", ts.Writes().Facts, legacy)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -83,6 +83,7 @@ func (g *gateServer) cleanupTask(t *testing.T, id string) {
|
||||
_ = g.m.pg.DeleteTask(n)
|
||||
_, _ = g.m.pg.Exec(`DELETE FROM target_pins WHERE task_id=$1`, n)
|
||||
_, _ = g.m.pg.Exec(`DELETE FROM intercept_pending WHERE task_id=$1`, id)
|
||||
_, _ = g.m.pg.Exec(`DELETE FROM assets WHERE type = 'ip' AND ip = '127.0.0.1'`)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,7 @@ func (f *targetScopeFixture) newTask(t *testing.T) *Task {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _, _ = f.m.DeleteTask(created.ID, DeleteTaskOptions{}) })
|
||||
task, ok := f.m.Task(created.ID)
|
||||
if !ok {
|
||||
t.Fatal("task not found after creation")
|
||||
|
||||
@@ -650,6 +650,15 @@ func TestTaskLLMResolutionReportsDatabaseFailure(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
taskID := mustTaskID(t, task.ID)
|
||||
t.Cleanup(func() {
|
||||
if dsn, _, err := db.DSN(); err == nil {
|
||||
if pg, err := db.Open(dsn); err == nil {
|
||||
_ = pg.DeleteTask(taskID)
|
||||
_ = pg.Close()
|
||||
}
|
||||
}
|
||||
})
|
||||
if err := m.pg.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -49,7 +49,14 @@ func TestTaskCredentialsFlow(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { s.m.PG().Exec(`DELETE FROM tasks WHERE id=$1`, id) })
|
||||
t.Cleanup(func() {
|
||||
_ = s.m.pg.DeleteTask(id)
|
||||
// The first POST with an invalid credential entry returns 400 after
|
||||
// creating a task/exploration row; remove any remaining fixture rows.
|
||||
_, _ = s.m.PG().Exec(`DELETE FROM tasks WHERE description = 'credential flow test'`)
|
||||
_, _ = s.m.PG().Exec(`DELETE FROM explorations WHERE description = 'credential flow test'`)
|
||||
_, _ = s.m.PG().Exec(`DELETE FROM assets WHERE type = 'ip' AND ip = '127.0.0.1'`)
|
||||
})
|
||||
|
||||
// List: both rows, user source, order stable.
|
||||
resp = request("GET", fmt.Sprintf("/api/tasks/%s/credentials", created.ID), "")
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestReviveClearsBudgetEndReason(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { pg.Exec(`DELETE FROM tasks WHERE id=$1`, id) })
|
||||
t.Cleanup(func() { _ = pg.DeleteTask(id) })
|
||||
endReason := func() string {
|
||||
t.Helper()
|
||||
var r string
|
||||
|
||||
+9
-11
@@ -193,20 +193,18 @@ func healthIDFor(prov llm.Provider, profileID int64) int64 {
|
||||
return profileID
|
||||
}
|
||||
|
||||
// current resolves the provider this role runs on, by precedence:
|
||||
// Agent binding → task LLM profile chain → global/environment configuration.
|
||||
// currentFor resolves the provider this role runs on, by precedence:
|
||||
// Agent binding → task LLM profile chain → global/environment configuration,
|
||||
// honoring a per-run profile pin set by the engine for per-intent rotation (#85).
|
||||
// Binding wins over the task chain: a role explicitly assigned a model keeps running
|
||||
// on that model; only when the binding is missing or fails to build does it fall back
|
||||
// to the task chain, and to the global configuration when the chain is empty.
|
||||
// The returned profile id is non-zero only on the task-chain path — streamTaskLLM uses it to decide whether a quota error should advance the task's failover state (binding/global paths leave the chain state untouched, preserving existing semantics).
|
||||
func (r *taskLLMRuntime) current() (taskLLMSelection, error) {
|
||||
return r.currentFor(context.Background())
|
||||
}
|
||||
|
||||
// currentFor resolves like current, honoring a per-run profile pin set by the
|
||||
// engine for per-intent rotation (#85). A pin is only a dispatch preference:
|
||||
// the chain must still be in a ready state (an exhausted chain with no active
|
||||
// head stays exhausted) and the pinned id must belong to the task's chain.
|
||||
// A pin is only a dispatch preference: the chain must still be in a ready state
|
||||
// (an exhausted chain with no active head stays exhausted) and the pinned id must
|
||||
// belong to the task's chain. The returned profile id is non-zero only on the
|
||||
// task-chain path — streamTaskLLM uses it to decide whether a quota error should
|
||||
// advance the task's failover state (binding/global paths leave the chain state
|
||||
// untouched, preserving existing semantics).
|
||||
func (r *taskLLMRuntime) currentFor(ctx context.Context) (taskLLMSelection, error) {
|
||||
taskNum, err := parseTaskID(r.taskID)
|
||||
if err != nil {
|
||||
|
||||
@@ -75,7 +75,10 @@ func TestRotationConcurrentProvidersAndPrecedence(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer m.DeleteTask(task.ID, DeleteTaskOptions{})
|
||||
defer func() {
|
||||
_, _ = m.pg.Exec(`DELETE FROM llm_usage WHERE task_id = $1`, task.ID)
|
||||
_, _ = m.DeleteTask(task.ID, DeleteTaskOptions{})
|
||||
}()
|
||||
s := &Server{m: m, provByProfile: map[int64]*provEntry{}}
|
||||
runtime := &taskLLMRuntime{s: s, taskID: task.ID, agentKey: "worker"}
|
||||
done := make(chan error, 3)
|
||||
@@ -343,7 +346,10 @@ func TestRunIntentRotatesPinnedProfileWithCachedExecCtx(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer m.DeleteTask(task.ID, DeleteTaskOptions{})
|
||||
defer func() {
|
||||
_, _ = m.pg.Exec(`DELETE FROM llm_usage WHERE task_id = $1`, task.ID)
|
||||
_, _ = m.DeleteTask(task.ID, DeleteTaskOptions{})
|
||||
}()
|
||||
|
||||
e := NewEngine(m)
|
||||
// Warm the per-task cached execCtx before any worker intent runs.
|
||||
|
||||
@@ -656,7 +656,7 @@ func TestProfileDeleteRestoresQuotaBlockedIntentWhenFallbackAvailable(t *testing
|
||||
if err != nil {
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
t.Cleanup(func() { _ = m.Close() })
|
||||
|
||||
profileID, err := m.pg.SaveProfile(&db.LLMProfile{
|
||||
Name: fmt.Sprintf("delete-quota-fallback-%d", time.Now().UnixNano()),
|
||||
|
||||
@@ -22,7 +22,10 @@ func TestTaskOutcomeCard(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
taskID, _ := strconv.ParseInt(task.ID, 10, 64)
|
||||
defer func() { _ = m.pg.DeleteTask(taskID) }()
|
||||
defer func() {
|
||||
_, _ = m.pg.DeleteFindingsByTask(taskID)
|
||||
_ = m.pg.DeleteTask(taskID)
|
||||
}()
|
||||
// skill_usage has no foreign keys, so DeleteTask leaves these rows behind,
|
||||
// and their misses would outrank TestSkillGapsReport's fixture in later runs.
|
||||
defer func() { _, _ = m.pg.Exec(`DELETE FROM skill_usage WHERE task_id=$1`, taskID) }()
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestPauseShiftsTaskDeadlineOnResume(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { pg.Exec(`DELETE FROM tasks WHERE id=$1`, id) })
|
||||
t.Cleanup(func() { _ = pg.DeleteTask(id) })
|
||||
|
||||
// A running task with a stamped deadline (first_run_at + 1h budget).
|
||||
if _, err := m.StampTaskFirstRun(task.ID); err != nil {
|
||||
|
||||
@@ -42,7 +42,7 @@ func (s *Server) resolutionFromProfile(p *db.LLMProfile, source string) taskLLMR
|
||||
return result
|
||||
}
|
||||
|
||||
// resolveTaskRoleLLM mirrors taskLLMRuntime.current without creating a provider:
|
||||
// resolveTaskRoleLLM mirrors taskLLMRuntime.currentFor without creating a provider:
|
||||
// role Agent binding -> explicit task chain -> active/global environment config.
|
||||
// Database failures are returned rather than represented as an unavailable model.
|
||||
func (s *Server) resolveTaskRoleLLM(t *Task, agentKey string) (taskLLMResolution, error) {
|
||||
|
||||
@@ -91,7 +91,7 @@ func TestConversationPatchReturnsPinState(t *testing.T) {
|
||||
if err != nil {
|
||||
db.SkipPGUnavailable(t, err)
|
||||
}
|
||||
defer m.Close()
|
||||
t.Cleanup(func() { _ = m.Close() })
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
s := New(ctx, m, t.TempDir(), t.TempDir(), t.TempDir())
|
||||
defer stopTestServer(t, s, cancel)
|
||||
|
||||
@@ -33,6 +33,14 @@ func meterTool(t actool.CoreTool, recorder toolUsageRecorder, toolKey, agentKey
|
||||
return &meteredTool{CoreTool: t, recorder: recorder, toolKey: toolKey, agentKey: agentKey, ri: ri}
|
||||
}
|
||||
|
||||
// AcceptsRawInput forwards the resolved tool's opt-out of the harness schema
|
||||
// check; the embedded interface alone would hide it from the harness's type
|
||||
// assertion.
|
||||
func (m *meteredTool) AcceptsRawInput() bool {
|
||||
r, ok := m.CoreTool.(interface{ AcceptsRawInput() bool })
|
||||
return ok && r.AcceptsRawInput()
|
||||
}
|
||||
|
||||
func (m *meteredTool) Call(ctx context.Context, input json.RawMessage, tc *actool.ToolContext) (actool.Result, error) {
|
||||
if err := m.recorder.InsertToolUsage(&db.ToolUsage{
|
||||
ToolKey: m.toolKey,
|
||||
|
||||
@@ -73,12 +73,19 @@ func TestWireTools(t *testing.T) {
|
||||
// Edit description + add a default to a scalar param, then confirm the resolved
|
||||
// worker tool reflects both. Restore from code default on cleanup.
|
||||
t.Cleanup(func() { _ = pg.UpsertToolForce(rf.Key, rf.Description, rf.Schema, mustJSON(rf.Agents)) })
|
||||
// Facts-only contract: the fact fields, and so the
|
||||
// editable scalar annotations, live on the facts[] items.
|
||||
var schema map[string]any
|
||||
_ = json.Unmarshal(rf.Schema, &schema)
|
||||
if props, ok := schema["properties"].(map[string]any); ok {
|
||||
if conf, ok := props["confidence"].(map[string]any); ok {
|
||||
conf["default"] = "inferred"
|
||||
}
|
||||
itemProps := func(sc map[string]any) map[string]any {
|
||||
props, _ := sc["properties"].(map[string]any)
|
||||
facts, _ := props["facts"].(map[string]any)
|
||||
items, _ := facts["items"].(map[string]any)
|
||||
ip, _ := items["properties"].(map[string]any)
|
||||
return ip
|
||||
}
|
||||
if conf, ok := itemProps(schema)["confidence"].(map[string]any); ok {
|
||||
conf["default"] = "inferred"
|
||||
}
|
||||
edited := mustJSON(schema)
|
||||
if err := pg.UpdateTool(rf.Key, "EDITED DESC", edited, mustJSON([]string{"worker"}), true); err != nil {
|
||||
@@ -96,9 +103,8 @@ func TestWireTools(t *testing.T) {
|
||||
// Default injection: omit confidence → handler input should carry the default.
|
||||
// We can't run the real handler (nil store), but InputSchema must show the default.
|
||||
sc := got.InputSchema()
|
||||
props := sc["properties"].(map[string]any)
|
||||
conf := props["confidence"].(map[string]any)
|
||||
if conf["default"] != "inferred" {
|
||||
conf, _ := itemProps(sc)["confidence"].(map[string]any)
|
||||
if conf == nil || conf["default"] != "inferred" {
|
||||
t.Errorf("confidence.default = %v, want inferred", conf["default"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,6 +269,7 @@ VALUES(?,?, 'HTTP/1.1 200 OK', ?, ?)`, id, "GET "+path+" HTTP/1.1\nHost: "+host,
|
||||
}
|
||||
tidV1, _ := strconv.ParseInt(taskV1.ID, 10, 64)
|
||||
t.Cleanup(func() {
|
||||
_, _ = s.m.pg.DeleteFindingsByTask(tidV1)
|
||||
_, _ = s.m.pg.Exec(`DELETE FROM task_archives WHERE task_id=$1`, tidV1)
|
||||
_ = s.m.pg.DeleteTask(tidV1)
|
||||
})
|
||||
|
||||
@@ -69,16 +69,6 @@ func workspacePathDenied(realRoot, realPath string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// wsResolve maps a user-supplied relative path to an absolute path INSIDE the work
|
||||
// dir. It returns ok=false if the path would escape the root (including via symlinks).
|
||||
func (s *Server) wsResolve(rel string) (string, bool) {
|
||||
cp, ok := s.wsResolveConfined(rel)
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
return cp.realPath, true
|
||||
}
|
||||
|
||||
// wsRel renders an absolute path back as a workspace-relative path (forward slashes).
|
||||
func (s *Server) wsRel(abs string) string {
|
||||
base, err := resolveRealRoot(s.m.dir)
|
||||
|
||||
+85
-85
@@ -13,7 +13,7 @@
|
||||
},
|
||||
"node_modules/@puppeteer/browsers": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmmirror.com/@puppeteer/browsers/-/browsers-2.6.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.6.1.tgz",
|
||||
"integrity": "sha512-aBSREisdsGH890S2rQqK82qmQYU3uFpSH8wcZWHgHzl3LfzsxAKbLNiAG9mO8v1Y0UICBeClICxPJvyr0rcuxg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -35,13 +35,13 @@
|
||||
},
|
||||
"node_modules/@tootallnate/quickjs-emscripten": {
|
||||
"version": "0.23.0",
|
||||
"resolved": "https://registry.npmmirror.com/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz",
|
||||
"integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "26.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/@types/node/-/node-26.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.0.1.tgz",
|
||||
"integrity": "sha512-fc3KiUoBt6kie0N9bIW3E47vZsuaMf0PM2AaUpLCLT0s/LvX1nxAim6Fc049cNxODPpGm6qRAuUOB86SkRuPQw==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
@@ -51,7 +51,7 @@
|
||||
},
|
||||
"node_modules/@types/yauzl": {
|
||||
"version": "2.10.3",
|
||||
"resolved": "https://registry.npmmirror.com/@types/yauzl/-/yauzl-2.10.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz",
|
||||
"integrity": "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
@@ -61,7 +61,7 @@
|
||||
},
|
||||
"node_modules/agent-base": {
|
||||
"version": "7.1.4",
|
||||
"resolved": "https://registry.npmmirror.com/agent-base/-/agent-base-7.1.4.tgz",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
|
||||
"integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -70,7 +70,7 @@
|
||||
},
|
||||
"node_modules/ansi-regex": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -79,7 +79,7 @@
|
||||
},
|
||||
"node_modules/ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -94,7 +94,7 @@
|
||||
},
|
||||
"node_modules/ast-types": {
|
||||
"version": "0.13.4",
|
||||
"resolved": "https://registry.npmmirror.com/ast-types/-/ast-types-0.13.4.tgz",
|
||||
"resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz",
|
||||
"integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -106,7 +106,7 @@
|
||||
},
|
||||
"node_modules/b4a": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmmirror.com/b4a/-/b4a-1.8.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/b4a/-/b4a-1.8.1.tgz",
|
||||
"integrity": "sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==",
|
||||
"license": "Apache-2.0",
|
||||
"peerDependencies": {
|
||||
@@ -120,7 +120,7 @@
|
||||
},
|
||||
"node_modules/bare-events": {
|
||||
"version": "2.9.1",
|
||||
"resolved": "https://registry.npmmirror.com/bare-events/-/bare-events-2.9.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.9.1.tgz",
|
||||
"integrity": "sha512-Z0oHEHAFDZkffN8Qc39zNZjQlMDkPJRyyyZieU1VH7u8c5S+qHZ2S8ixdKIAxEjfHO7FJxXmJWgteOghVanIsg==",
|
||||
"license": "Apache-2.0",
|
||||
"peerDependencies": {
|
||||
@@ -134,7 +134,7 @@
|
||||
},
|
||||
"node_modules/bare-fs": {
|
||||
"version": "4.7.2",
|
||||
"resolved": "https://registry.npmmirror.com/bare-fs/-/bare-fs-4.7.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.7.2.tgz",
|
||||
"integrity": "sha512-aTvMFUWkBmjzKtEQMDGGDNF8bkfpD5N1b/FCwt7A3wrU4t1o/e/85Wzkluh6JlODCjqVESYCkQCdTXqZ9G7VFg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -158,7 +158,7 @@
|
||||
},
|
||||
"node_modules/bare-os": {
|
||||
"version": "3.9.3",
|
||||
"resolved": "https://registry.npmmirror.com/bare-os/-/bare-os-3.9.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/bare-os/-/bare-os-3.9.3.tgz",
|
||||
"integrity": "sha512-fF4Q7QsyKVF5Rj0qvI8BgUNjqzC2JvQlpTaPLjVJVxYVUX5Zr9un+y3w1HmA4nNKdFmRBT8z/WmrjvXzXVerKQ==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
@@ -167,7 +167,7 @@
|
||||
},
|
||||
"node_modules/bare-path": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/bare-path/-/bare-path-3.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.0.1.tgz",
|
||||
"integrity": "sha512-ghj2DSK/2e99a1anTVPCV4m4YIYtrbXhfM7V3D7XZLOTsybnYyaJloymGqssQc8l/or0UoDyRtNQkmkEF/ysgQ==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -176,7 +176,7 @@
|
||||
},
|
||||
"node_modules/bare-stream": {
|
||||
"version": "2.13.3",
|
||||
"resolved": "https://registry.npmmirror.com/bare-stream/-/bare-stream-2.13.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.13.3.tgz",
|
||||
"integrity": "sha512-Kc+brLqvEqGkjyfiwJmImAOqLZL7OsoLKuavx+hJjgVV3nLTOjloJyPMFxjUPerGGHrNH0fLU06jjykMLWrERQ==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -203,7 +203,7 @@
|
||||
},
|
||||
"node_modules/bare-url": {
|
||||
"version": "2.4.5",
|
||||
"resolved": "https://registry.npmmirror.com/bare-url/-/bare-url-2.4.5.tgz",
|
||||
"resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.4.5.tgz",
|
||||
"integrity": "sha512-K+y9xF1tN+CdPu4qWwr0QiK1Al07eFPGYK5M2pDXcmHdMdgC/tT/bpmMe1hrmRHaidKLkXrC+cRNYf3XVDUhSQ==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -212,7 +212,7 @@
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmmirror.com/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||
"funding": [
|
||||
{
|
||||
@@ -232,7 +232,7 @@
|
||||
},
|
||||
"node_modules/basic-ftp": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/basic-ftp/-/basic-ftp-5.3.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.3.1.tgz",
|
||||
"integrity": "sha512-bopVNp6ugyA150DDuZfPFdt1KZ5a94ZDiwX4hMgZDzF+GttD80lEy8kj98kbyhLXnPvhtIo93mdnLIjpCAeeOw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -241,7 +241,7 @@
|
||||
},
|
||||
"node_modules/buffer": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmmirror.com/buffer/-/buffer-5.7.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
||||
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
||||
"funding": [
|
||||
{
|
||||
@@ -265,7 +265,7 @@
|
||||
},
|
||||
"node_modules/buffer-crc32": {
|
||||
"version": "0.2.13",
|
||||
"resolved": "https://registry.npmmirror.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
|
||||
"resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
|
||||
"integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -274,7 +274,7 @@
|
||||
},
|
||||
"node_modules/chromium-bidi": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmmirror.com/chromium-bidi/-/chromium-bidi-0.11.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.11.0.tgz",
|
||||
"integrity": "sha512-6CJWHkNRoyZyjV9Rwv2lYONZf1Xm0IuDyNq97nwSsxxP3wf5Bwy15K5rOvVKMtJ127jJBmxFUanSAOjgFRxgrA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -287,7 +287,7 @@
|
||||
},
|
||||
"node_modules/cliui": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/cliui/-/cliui-8.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
||||
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -301,7 +301,7 @@
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -313,13 +313,13 @@
|
||||
},
|
||||
"node_modules/color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/data-uri-to-buffer": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz",
|
||||
"integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -328,7 +328,7 @@
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmmirror.com/debug/-/debug-4.4.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -345,7 +345,7 @@
|
||||
},
|
||||
"node_modules/degenerator": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/degenerator/-/degenerator-5.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz",
|
||||
"integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -359,19 +359,19 @@
|
||||
},
|
||||
"node_modules/devtools-protocol": {
|
||||
"version": "0.0.1367902",
|
||||
"resolved": "https://registry.npmmirror.com/devtools-protocol/-/devtools-protocol-0.0.1367902.tgz",
|
||||
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1367902.tgz",
|
||||
"integrity": "sha512-XxtPuC3PGakY6PD7dG66/o8KwJ/LkH2/EKe19Dcw58w53dv4/vSQEkn/SzuyhHE2q4zPgCkxQBxus3VV4ql+Pg==",
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/end-of-stream": {
|
||||
"version": "1.4.5",
|
||||
"resolved": "https://registry.npmmirror.com/end-of-stream/-/end-of-stream-1.4.5.tgz",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
|
||||
"integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -380,7 +380,7 @@
|
||||
},
|
||||
"node_modules/escalade": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/escalade/-/escalade-3.2.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
||||
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -389,7 +389,7 @@
|
||||
},
|
||||
"node_modules/escodegen": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/escodegen/-/escodegen-2.1.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz",
|
||||
"integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
@@ -410,7 +410,7 @@
|
||||
},
|
||||
"node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/esprima/-/esprima-4.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"license": "BSD-2-Clause",
|
||||
"bin": {
|
||||
@@ -423,7 +423,7 @@
|
||||
},
|
||||
"node_modules/estraverse": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/estraverse/-/estraverse-5.3.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
|
||||
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
@@ -432,7 +432,7 @@
|
||||
},
|
||||
"node_modules/esutils": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmmirror.com/esutils/-/esutils-2.0.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
@@ -441,7 +441,7 @@
|
||||
},
|
||||
"node_modules/events-universal": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/events-universal/-/events-universal-1.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz",
|
||||
"integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -450,7 +450,7 @@
|
||||
},
|
||||
"node_modules/extract-zip": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/extract-zip/-/extract-zip-2.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz",
|
||||
"integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
@@ -470,13 +470,13 @@
|
||||
},
|
||||
"node_modules/fast-fifo": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmmirror.com/fast-fifo/-/fast-fifo-1.3.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz",
|
||||
"integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fd-slicer": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/fd-slicer/-/fd-slicer-1.1.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
|
||||
"integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -485,7 +485,7 @@
|
||||
},
|
||||
"node_modules/get-caller-file": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmmirror.com/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
@@ -494,7 +494,7 @@
|
||||
},
|
||||
"node_modules/get-stream": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/get-stream/-/get-stream-5.2.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
|
||||
"integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -509,7 +509,7 @@
|
||||
},
|
||||
"node_modules/get-uri": {
|
||||
"version": "6.0.5",
|
||||
"resolved": "https://registry.npmmirror.com/get-uri/-/get-uri-6.0.5.tgz",
|
||||
"resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.5.tgz",
|
||||
"integrity": "sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -523,7 +523,7 @@
|
||||
},
|
||||
"node_modules/http-proxy-agent": {
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz",
|
||||
"integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -536,7 +536,7 @@
|
||||
},
|
||||
"node_modules/https-proxy-agent": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmmirror.com/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
|
||||
"integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -549,7 +549,7 @@
|
||||
},
|
||||
"node_modules/ieee754": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/ieee754/-/ieee754-1.2.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
|
||||
"funding": [
|
||||
{
|
||||
@@ -569,7 +569,7 @@
|
||||
},
|
||||
"node_modules/ip-address": {
|
||||
"version": "10.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/ip-address/-/ip-address-10.2.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.2.0.tgz",
|
||||
"integrity": "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -578,7 +578,7 @@
|
||||
},
|
||||
"node_modules/is-fullwidth-code-point": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -587,7 +587,7 @@
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "7.18.3",
|
||||
"resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-7.18.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz",
|
||||
"integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
@@ -596,19 +596,19 @@
|
||||
},
|
||||
"node_modules/mitt": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/mitt/-/mitt-3.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz",
|
||||
"integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/netmask": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/netmask/-/netmask-2.1.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/netmask/-/netmask-2.1.1.tgz",
|
||||
"integrity": "sha512-eonl3sLUha+S1GzTPxychyhnUzKyeQkZ7jLjKrBagJgPla13F+uQ71HgpFefyHgqrjEbCPkDArxYsjY8/+gLKA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -617,7 +617,7 @@
|
||||
},
|
||||
"node_modules/once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/once/-/once-1.4.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
@@ -626,7 +626,7 @@
|
||||
},
|
||||
"node_modules/pac-proxy-agent": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/pac-proxy-agent/-/pac-proxy-agent-7.2.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.2.0.tgz",
|
||||
"integrity": "sha512-TEB8ESquiLMc0lV8vcd5Ql/JAKAoyzHFXaStwjkzpOpC5Yv+pIzLfHvjTSdf3vpa2bMiUQrg9i6276yn8666aA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -645,7 +645,7 @@
|
||||
},
|
||||
"node_modules/pac-resolver": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/pac-resolver/-/pac-resolver-7.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz",
|
||||
"integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -658,13 +658,13 @@
|
||||
},
|
||||
"node_modules/pend": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/pend/-/pend-1.2.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
|
||||
"integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/progress": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmmirror.com/progress/-/progress-2.0.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
|
||||
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -673,7 +673,7 @@
|
||||
},
|
||||
"node_modules/proxy-agent": {
|
||||
"version": "6.5.0",
|
||||
"resolved": "https://registry.npmmirror.com/proxy-agent/-/proxy-agent-6.5.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.5.0.tgz",
|
||||
"integrity": "sha512-TmatMXdr2KlRiA2CyDu8GqR8EjahTG3aY3nXjdzFyoZbmB8hrBsTyMezhULIXKnC0jpfjlmiZ3+EaCzoInSu/A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -692,13 +692,13 @@
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pump": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/pump/-/pump-3.0.4.tgz",
|
||||
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz",
|
||||
"integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -708,7 +708,7 @@
|
||||
},
|
||||
"node_modules/puppeteer-core": {
|
||||
"version": "23.11.1",
|
||||
"resolved": "https://registry.npmmirror.com/puppeteer-core/-/puppeteer-core-23.11.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.11.1.tgz",
|
||||
"integrity": "sha512-3HZ2/7hdDKZvZQ7dhhITOUg4/wOrDRjyK2ZBllRB0ZCOi9u0cwq1ACHDjBB+nX+7+kltHjQvBRdeY7+W0T+7Gg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -725,7 +725,7 @@
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/require-directory/-/require-directory-2.1.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -734,7 +734,7 @@
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "7.8.5",
|
||||
"resolved": "https://registry.npmmirror.com/semver/-/semver-7.8.5.tgz",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
@@ -746,7 +746,7 @@
|
||||
},
|
||||
"node_modules/smart-buffer": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/smart-buffer/-/smart-buffer-4.2.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
|
||||
"integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -756,7 +756,7 @@
|
||||
},
|
||||
"node_modules/socks": {
|
||||
"version": "2.8.9",
|
||||
"resolved": "https://registry.npmmirror.com/socks/-/socks-2.8.9.tgz",
|
||||
"resolved": "https://registry.npmjs.org/socks/-/socks-2.8.9.tgz",
|
||||
"integrity": "sha512-LJhUYUvItdQ0LkJTmPeaEObWXAqFyfmP85x0tch/ez9cahmhlBBLbIqDFnvBnUJGagb0JbIQrkBs1wJ+yRYpEw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -770,7 +770,7 @@
|
||||
},
|
||||
"node_modules/socks-proxy-agent": {
|
||||
"version": "8.0.5",
|
||||
"resolved": "https://registry.npmmirror.com/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz",
|
||||
"resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz",
|
||||
"integrity": "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -784,7 +784,7 @@
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"license": "BSD-3-Clause",
|
||||
"optional": true,
|
||||
@@ -794,7 +794,7 @@
|
||||
},
|
||||
"node_modules/streamx": {
|
||||
"version": "2.28.0",
|
||||
"resolved": "https://registry.npmmirror.com/streamx/-/streamx-2.28.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/streamx/-/streamx-2.28.0.tgz",
|
||||
"integrity": "sha512-1Yowhzjf0ivGMrTIkY9hav5TxobO9qIVqUE41fiCGMGgc3CLlf4MY+9AHmZqBWgDTue0fY9zWjYFVyf6Diuobw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -805,7 +805,7 @@
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -819,7 +819,7 @@
|
||||
},
|
||||
"node_modules/strip-ansi": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -831,7 +831,7 @@
|
||||
},
|
||||
"node_modules/tar-fs": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmmirror.com/tar-fs/-/tar-fs-3.1.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.1.3.tgz",
|
||||
"integrity": "sha512-/hU4AXnIdZu+Gvl1pk0oI5f5HxWsCJRtY2aFaJdk9VvyL48DWU6iU5WAIPG+wIi1YvWA6eTJvIviP/tMAZZNwQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -845,7 +845,7 @@
|
||||
},
|
||||
"node_modules/tar-stream": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/tar-stream/-/tar-stream-3.2.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.2.0.tgz",
|
||||
"integrity": "sha512-ojzvCvVaNp6aOTFmG7jaRD0meowIAuPc3cMMhSgKiVWws1GyHbGd/xvnyuRKcKlMpt3qvxx6r0hreCNITP9hIg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -857,7 +857,7 @@
|
||||
},
|
||||
"node_modules/teex": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/teex/-/teex-1.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/teex/-/teex-1.0.1.tgz",
|
||||
"integrity": "sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -866,7 +866,7 @@
|
||||
},
|
||||
"node_modules/text-decoder": {
|
||||
"version": "1.2.7",
|
||||
"resolved": "https://registry.npmmirror.com/text-decoder/-/text-decoder-1.2.7.tgz",
|
||||
"resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.7.tgz",
|
||||
"integrity": "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -875,25 +875,25 @@
|
||||
},
|
||||
"node_modules/through": {
|
||||
"version": "2.3.8",
|
||||
"resolved": "https://registry.npmmirror.com/through/-/through-2.3.8.tgz",
|
||||
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
|
||||
"integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/typed-query-selector": {
|
||||
"version": "2.12.2",
|
||||
"resolved": "https://registry.npmmirror.com/typed-query-selector/-/typed-query-selector-2.12.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.2.tgz",
|
||||
"integrity": "sha512-EOPFbyIub4ngnEdqi2yOcNeDLaX/0jcE1JoAXQDDMIthap7FoN795lc/SHfIq2d416VufXpM8z/lD+WRm2gfOQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/unbzip2-stream": {
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmmirror.com/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz",
|
||||
"integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -903,14 +903,14 @@
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "8.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-8.3.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
|
||||
"integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/wrap-ansi": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
||||
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -927,13 +927,13 @@
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.21.0",
|
||||
"resolved": "https://registry.npmmirror.com/ws/-/ws-8.21.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz",
|
||||
"integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -954,7 +954,7 @@
|
||||
},
|
||||
"node_modules/y18n": {
|
||||
"version": "5.0.8",
|
||||
"resolved": "https://registry.npmmirror.com/y18n/-/y18n-5.0.8.tgz",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
@@ -963,7 +963,7 @@
|
||||
},
|
||||
"node_modules/yargs": {
|
||||
"version": "17.7.3",
|
||||
"resolved": "https://registry.npmmirror.com/yargs/-/yargs-17.7.3.tgz",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.3.tgz",
|
||||
"integrity": "sha512-GZtjxm/J/4TSxuL3FNYjCmLktBTnIw/rVmKSIyKeYAZpmJB2ig9VauCC5xsa82GNKVKDAqpOn3KVzNt0zmrU0g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -981,7 +981,7 @@
|
||||
},
|
||||
"node_modules/yargs-parser": {
|
||||
"version": "21.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/yargs-parser/-/yargs-parser-21.1.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
|
||||
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
@@ -990,7 +990,7 @@
|
||||
},
|
||||
"node_modules/yauzl": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmmirror.com/yauzl/-/yauzl-2.10.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
|
||||
"integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -1000,7 +1000,7 @@
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "3.23.8",
|
||||
"resolved": "https://registry.npmmirror.com/zod/-/zod-3.23.8.tgz",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
|
||||
"integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
|
||||
@@ -56,7 +56,7 @@ update_local(){
|
||||
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
info "Rebuilding frontend static assets…"
|
||||
( cd web && npm ci && npm run build:static )
|
||||
( cd web && npm ci --ignore-scripts && npm run build:static )
|
||||
rm -rf server/webui/dist && cp -r web/out server/webui/dist
|
||||
info "Recompiling the embedded single binary…"
|
||||
CGO_ENABLED=0 go build -tags embedui -trimpath -o artex ./cmd/artex
|
||||
|
||||
Generated
+1
-321
@@ -11,51 +11,33 @@
|
||||
"@antv/g6": "^5.1.1",
|
||||
"@base-ui/react": "^1.6.0",
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/modifiers": "^9.0.0",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@fullcalendar/react": "^7.0.0",
|
||||
"@hookform/resolvers": "^5.4.0",
|
||||
"@shadcn/react": "^0.1.0",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@xyflow/react": "^12.3.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
"d3-geo": "^3.1.1",
|
||||
"date-fns": "^4.4.0",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
"geist": "^1.7.2",
|
||||
"input-otp": "^1.4.2",
|
||||
"lucide-react": "^1.22.0",
|
||||
"next": "^16.4.6",
|
||||
"next-themes": "^0.4.6",
|
||||
"radix-ui": "^1.6.0",
|
||||
"react": "^19.2.7",
|
||||
"react-day-picker": "^10.0.1",
|
||||
"react-dom": "^19.2.7",
|
||||
"react-hook-form": "^7.80.0",
|
||||
"react-is": "^19.2.7",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-resizable-panels": "^4.12.0",
|
||||
"recharts": "^3.8.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"simple-icons": "^16.24.1",
|
||||
"sonner": "^2.0.7",
|
||||
"tailwind-merge": "^3.6.0",
|
||||
"temporal-polyfill": "^1.0.1",
|
||||
"topojson-client": "^3.1.0",
|
||||
"vaul": "^1.1.2",
|
||||
"zod": "^4.4.3",
|
||||
"zustand": "^5.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.5.1",
|
||||
"@tailwindcss/postcss": "^4.3.2",
|
||||
"@types/d3-geo": "^3.1.0",
|
||||
"@types/node": "^22.20.0",
|
||||
"@types/react": "^19.2.17",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@types/topojson-client": "^3.1.5",
|
||||
"babel-plugin-react-compiler": "^1.0.0",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^16.4.0",
|
||||
@@ -1004,12 +986,6 @@
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@date-fns/tz": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@date-fns/tz/-/tz-1.5.0.tgz",
|
||||
"integrity": "sha512-lwYN/vDPeNRULcepoE/LO2Pgx+7/RV+S9ARfbc9lr2DtGkOD7pAiruHvbR1RX3Qyf6ja47EWJDMsNK5vK08DJg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@dnd-kit/accessibility": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@dnd-kit/accessibility/-/accessibility-3.1.1.tgz",
|
||||
@@ -1037,34 +1013,6 @@
|
||||
"react-dom": ">=16.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@dnd-kit/modifiers": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@dnd-kit/modifiers/-/modifiers-9.0.0.tgz",
|
||||
"integrity": "sha512-ybiLc66qRGuZoC20wdSSG6pDXFikui/dCNGthxv4Ndy8ylErY0N3KVxY2bgo7AWwIbxDmXDg3ylAFmnrjcbVvw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"tslib": "^2.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@dnd-kit/core": "^6.3.0",
|
||||
"react": ">=16.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@dnd-kit/sortable": {
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@dnd-kit/sortable/-/sortable-10.0.0.tgz",
|
||||
"integrity": "sha512-+xqhmIIzvAYMGfBYYnbKuNicfSsk4RksY2XdmJhT+HAC01nix6fHCztU68jooFiMUB01Ky3F0FyOvhG/BZrWkg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"tslib": "^2.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@dnd-kit/core": "^6.3.0",
|
||||
"react": ">=16.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@dnd-kit/utilities": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@dnd-kit/utilities/-/utilities-3.2.2.tgz",
|
||||
@@ -1346,40 +1294,6 @@
|
||||
"integrity": "sha512-RiB/yIh78pcIxl6lLMG0CgBXAZ2Y0eVHqMPYugu+9U0AeT6YBeiJpf7lbdJNIugFP5SIjwNRgo4DhR1Qxi26Gg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@full-ui/headless-calendar": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@full-ui/headless-calendar/-/headless-calendar-7.0.0.tgz",
|
||||
"integrity": "sha512-47Y2NoiSt/DJy/+PD9yv4OLhaVJqn8oknFXhS6kiMnoXSOiYkoz6gqVIOCF2nvvQPqKUepb3W3403Qj34QfjtQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"temporal-polyfill": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@fullcalendar/core": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@fullcalendar/core/-/core-7.0.0.tgz",
|
||||
"integrity": "sha512-cZobng3rB7PQp8zdRp7SIeA4ZEvOWhnwHuFWQf3xXIM9BPfmKb5EFhpiNHCT6zzn041A2wv9ztqiQ60S1sY5KA==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@full-ui/headless-calendar": "7.0.0",
|
||||
"temporal-polyfill": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@fullcalendar/react": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@fullcalendar/react/-/react-7.0.0.tgz",
|
||||
"integrity": "sha512-klabENcKYXPom8UB8eTzLSaSNeB/gpe11XVBOnjnsVmOJqLftnkBBQXtAF6lFuXQrj0goHdIan8xicOTLJhSeA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@full-ui/headless-calendar": "7.0.0",
|
||||
"@fullcalendar/core": "7.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^17 || ^18 || ^19",
|
||||
"react-dom": "^17 || ^18 || ^19",
|
||||
"temporal-polyfill": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@hono/node-server": {
|
||||
"version": "1.19.14",
|
||||
"resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.19.14.tgz",
|
||||
@@ -1393,18 +1307,6 @@
|
||||
"hono": "^4"
|
||||
}
|
||||
},
|
||||
"node_modules/@hookform/resolvers": {
|
||||
"version": "5.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-5.4.0.tgz",
|
||||
"integrity": "sha512-EIsqr/t/qbinPIhGjMdtvutIN1Kk4uwbROE9/UQ93CAVGR7GkA7Y92+fX80OzXi/OB67jVFYwKGO1WzkxmkFZw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@standard-schema/utils": "^0.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react-hook-form": "^7.55.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/colour": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz",
|
||||
@@ -3765,24 +3667,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@shadcn/react": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@shadcn/react/-/react-0.1.0.tgz",
|
||||
"integrity": "sha512-6i67TEnqValsZY7e4exJ4rkHo2OdHXmDH152YulwSpuEUnTQYumHkXzFsaje7HB7GbMTWuI9x1Jn6sSduCYdeA==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@types/react": ">=19",
|
||||
"react": ">=19"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"react": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@sindresorhus/merge-streams": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz",
|
||||
@@ -4088,39 +3972,6 @@
|
||||
"tailwindcss": "4.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/react-table": {
|
||||
"version": "8.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/react-table/-/react-table-8.21.3.tgz",
|
||||
"integrity": "sha512-5nNMTSETP4ykGegmVkhjcS8tTLW6Vl4axfEGQN3v0zdHYbK4UfoqfPChclTrJ4EoK9QynqAu9oUf8VEmrpZ5Ww==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/table-core": "8.21.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.8",
|
||||
"react-dom": ">=16.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/table-core": {
|
||||
"version": "8.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/table-core/-/table-core-8.21.3.tgz",
|
||||
"integrity": "sha512-ldZXEhOBb8Is7xLs01fR3YEc3DERiz5silj8tnGkFZytt1abEvl/GhUmCE0PMLaMPTa3Jk4HbKmRlHmu+gCftg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
}
|
||||
},
|
||||
"node_modules/@ts-morph/common": {
|
||||
"version": "0.27.0",
|
||||
"resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.27.0.tgz",
|
||||
@@ -4407,27 +4258,6 @@
|
||||
"@types/react": "^19.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/topojson-client": {
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/topojson-client/-/topojson-client-3.1.5.tgz",
|
||||
"integrity": "sha512-C79rySTyPxnQNNguTZNI1Ct4D7IXgvyAs3p9HPecnl6mNrJ5+UhvGNYcZfpROYV2lMHI48kJPxwR+F9C6c7nmw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/geojson": "*",
|
||||
"@types/topojson-specification": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/topojson-specification": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/topojson-specification/-/topojson-specification-1.0.5.tgz",
|
||||
"integrity": "sha512-C7KvcQh+C2nr6Y2Ub4YfgvWvWCgP2nOQMtfhlnwsRL4pYmmwzBS7HclGiS87eQfDOU/DLQpX6GEscviaz4yLIQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/geojson": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/unist": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz",
|
||||
@@ -5799,16 +5629,6 @@
|
||||
"lodash": "^4.17.15"
|
||||
}
|
||||
},
|
||||
"node_modules/date-fns": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.4.0.tgz",
|
||||
"integrity": "sha512-+1UMbeh68lH1SegH83CGWwpb6OHHbpSgr3+s5Eww5M4CAgswBpoWS0AjTOfEJ33HiYKz1hdj/KTFprzXHmq/6w==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/kossnocorp"
|
||||
}
|
||||
},
|
||||
"node_modules/debounce-fn": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/debounce-fn/-/debounce-fn-4.0.0.tgz",
|
||||
@@ -6045,34 +5865,6 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/embla-carousel": {
|
||||
"version": "8.6.0",
|
||||
"resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.6.0.tgz",
|
||||
"integrity": "sha512-SjWyZBHJPbqxHOzckOfo8lHisEaJWmwd23XppYFYVh10bU66/Pn5tkVkbkCMZVdbUE5eTCI2nD8OyIP4Z+uwkA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/embla-carousel-react": {
|
||||
"version": "8.6.0",
|
||||
"resolved": "https://registry.npmjs.org/embla-carousel-react/-/embla-carousel-react-8.6.0.tgz",
|
||||
"integrity": "sha512-0/PjqU7geVmo6F734pmPqpyHqiM99olvyecY7zdweCw+6tKEXnrE90pBiBbMMU8s5tICemzpQ3hi5EpxzGW+JA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"embla-carousel": "8.6.0",
|
||||
"embla-carousel-reactive-utils": "8.6.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.1 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"
|
||||
}
|
||||
},
|
||||
"node_modules/embla-carousel-reactive-utils": {
|
||||
"version": "8.6.0",
|
||||
"resolved": "https://registry.npmjs.org/embla-carousel-reactive-utils/-/embla-carousel-reactive-utils-8.6.0.tgz",
|
||||
"integrity": "sha512-fMVUDUEx0/uIEDM0Mz3dHznDhfX+znCCDCeIophYb1QGVM7YThSWX+wz11zlYwWFOr74b4QLGg0hrGPJeG2s4A==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"embla-carousel": "8.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "10.6.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
||||
@@ -6966,16 +6758,6 @@
|
||||
"integrity": "sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/input-otp": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/input-otp/-/input-otp-1.4.2.tgz",
|
||||
"integrity": "sha512-l3jWwYNvrEa6NTCt7BECfCm48GvwuZzkoeG3gBL2w4CHeOXW3eKFmf9UNYkNfYc3mxMrthMnxjIE07MT0zLBQA==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0.0 || ^19.0.0-rc"
|
||||
}
|
||||
},
|
||||
"node_modules/internmap": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz",
|
||||
@@ -9608,32 +9390,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-day-picker": {
|
||||
"version": "10.0.1",
|
||||
"resolved": "https://registry.npmjs.org/react-day-picker/-/react-day-picker-10.0.1.tgz",
|
||||
"integrity": "sha512-eNh6BlwcYInWaJtRv18mXQ06Ys/H6rdTZAnTaSdOYJuTpwP1JMCHNd1FDRadA+gbeinq+psdULN5Xnowy9mV8w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@date-fns/tz": "^1.4.1",
|
||||
"date-fns": "^4.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/gpbl"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": ">=16.8.0",
|
||||
"react": ">=16.8.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-dom": {
|
||||
"version": "19.2.7",
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.7.tgz",
|
||||
@@ -9646,22 +9402,6 @@
|
||||
"react": "^19.2.7"
|
||||
}
|
||||
},
|
||||
"node_modules/react-hook-form": {
|
||||
"version": "7.80.0",
|
||||
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.80.0.tgz",
|
||||
"integrity": "sha512-4P+fk6oXsxY+6xSj7Euhc2sumQD8zQqCuVHoJwoyp9EchP+IUW9OESB7uHFJOKsIBQ4MQqYE84INJFqUCYNoOg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/react-hook-form"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17 || ^18 || ^19"
|
||||
}
|
||||
},
|
||||
"node_modules/react-is": {
|
||||
"version": "19.2.7",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.7.tgz",
|
||||
@@ -10360,25 +10100,6 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/simple-icons": {
|
||||
"version": "16.24.1",
|
||||
"resolved": "https://registry.npmjs.org/simple-icons/-/simple-icons-16.24.1.tgz",
|
||||
"integrity": "sha512-AnDQPrZAVzYSym7cBVIrnbhLk9auWGgkl+9hKvkbTqGEfH6TU7WKgumEXYYaJuM1Ib87+cnzr881UZniCM7t+A==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/simple-icons"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/simple-icons"
|
||||
}
|
||||
],
|
||||
"license": "CC0-1.0",
|
||||
"engines": {
|
||||
"node": ">=0.12.18"
|
||||
}
|
||||
},
|
||||
"node_modules/simple-swizzle": {
|
||||
"version": "0.2.4",
|
||||
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.4.tgz",
|
||||
@@ -10696,28 +10417,6 @@
|
||||
"url": "https://opencollective.com/webpack"
|
||||
}
|
||||
},
|
||||
"node_modules/temporal-polyfill": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-1.0.1.tgz",
|
||||
"integrity": "sha512-N2SoI9olnW7BUsU8RosDphZQl9s+WJ8O7PoJMFCr/e5/1rFkVI4GNOWaSeySG+UoP04foPYsnLWbJmbXOiShZg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"temporal-spec": "1.0.0",
|
||||
"temporal-utils": "1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/temporal-spec": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/temporal-spec/-/temporal-spec-1.0.0.tgz",
|
||||
"integrity": "sha512-00Ahj1e1ifaERTMOIIGpOCdOo9IEk2m6GGSMedsn9a2SIsGLdOTbmME1Htv6IM82b6VHrzSUTIVc7YHy6hdhFQ==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/temporal-utils": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/temporal-utils/-/temporal-utils-1.0.1.tgz",
|
||||
"integrity": "sha512-HAixuesxFQIUaQk3ptX2jhfO/FsOkgVkDDMawvp6n/fkB1q6BKfs3lURw9I+pK/2e2e/q/vrLrxmeqauBoyGMQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/text-segmentation": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz",
|
||||
@@ -10766,26 +10465,6 @@
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/topojson-client": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/topojson-client/-/topojson-client-3.1.0.tgz",
|
||||
"integrity": "sha512-605uxS6bcYxGXw9qi62XyrV6Q3xwbndjachmNxu8HWTtVPxZfEJN9fd/SZS1Q54Sn2y0TMyMxFj/cJINqGHrKw==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"commander": "2"
|
||||
},
|
||||
"bin": {
|
||||
"topo2geo": "bin/topo2geo",
|
||||
"topomerge": "bin/topomerge",
|
||||
"topoquantize": "bin/topoquantize"
|
||||
}
|
||||
},
|
||||
"node_modules/topojson-client/node_modules/commander": {
|
||||
"version": "2.20.3",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/trim-lines": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",
|
||||
@@ -11417,6 +11096,7 @@
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
|
||||
"integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
|
||||
+1
-19
@@ -16,7 +16,7 @@
|
||||
"test:polling": "node --test scripts/polling.test.mjs",
|
||||
"test:replay": "node --test scripts/replay.test.mjs",
|
||||
"test:upload": "node --test scripts/upload.test.mjs",
|
||||
"test:i18n": "node scripts/check-i18n.mjs"
|
||||
"test:i18n": "node scripts/check-i18n.mjs && node --test scripts/i18n.test.mjs"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,ts,jsx,tsx}": [
|
||||
@@ -27,51 +27,33 @@
|
||||
"@antv/g6": "^5.1.1",
|
||||
"@base-ui/react": "^1.6.0",
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/modifiers": "^9.0.0",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@fullcalendar/react": "^7.0.0",
|
||||
"@hookform/resolvers": "^5.4.0",
|
||||
"@shadcn/react": "^0.1.0",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@xyflow/react": "^12.3.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
"d3-geo": "^3.1.1",
|
||||
"date-fns": "^4.4.0",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
"geist": "^1.7.2",
|
||||
"input-otp": "^1.4.2",
|
||||
"lucide-react": "^1.22.0",
|
||||
"next": "^16.4.6",
|
||||
"next-themes": "^0.4.6",
|
||||
"radix-ui": "^1.6.0",
|
||||
"react": "^19.2.7",
|
||||
"react-day-picker": "^10.0.1",
|
||||
"react-dom": "^19.2.7",
|
||||
"react-hook-form": "^7.80.0",
|
||||
"react-is": "^19.2.7",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-resizable-panels": "^4.12.0",
|
||||
"recharts": "^3.8.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"simple-icons": "^16.24.1",
|
||||
"sonner": "^2.0.7",
|
||||
"tailwind-merge": "^3.6.0",
|
||||
"temporal-polyfill": "^1.0.1",
|
||||
"topojson-client": "^3.1.0",
|
||||
"vaul": "^1.1.2",
|
||||
"zod": "^4.4.3",
|
||||
"zustand": "^5.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.5.1",
|
||||
"@tailwindcss/postcss": "^4.3.2",
|
||||
"@types/d3-geo": "^3.1.0",
|
||||
"@types/node": "^22.20.0",
|
||||
"@types/react": "^19.2.17",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@types/topojson-client": "^3.1.5",
|
||||
"babel-plugin-react-compiler": "^1.0.0",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^16.4.0",
|
||||
|
||||
+27
-30
@@ -2,11 +2,14 @@ import { readFileSync, readdirSync, statSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
// Every literal t("...") / t('...') key must exist in the locale dictionary
|
||||
// with the same {placeholders}. Dynamic keys (variables, template literals
|
||||
// with ${}) are skipped: there is nothing to compare them against.
|
||||
// English source text is the key. Check every shipped dictionary, including
|
||||
// dynamic entries, while retaining the existing literal-call coverage check.
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const dict = JSON.parse(readFileSync(join(root, "src/i18n/locales/tr.json"), "utf8"));
|
||||
const localeDir = join(root, "src/i18n/locales");
|
||||
const dictionaries = readdirSync(localeDir)
|
||||
.filter((name) => name.endsWith(".json"))
|
||||
.sort()
|
||||
.map((name) => [name, JSON.parse(readFileSync(join(localeDir, name), "utf8"))]);
|
||||
|
||||
const files = [];
|
||||
function walk(dir) {
|
||||
@@ -19,7 +22,7 @@ function walk(dir) {
|
||||
}
|
||||
walk(join(root, "src"));
|
||||
|
||||
const calls = new Map(); // key -> first file that uses it
|
||||
const calls = new Map();
|
||||
const literalCall = /(?:^|[^\w$.])t\(\s*(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)')/gm;
|
||||
for (const file of files) {
|
||||
const src = readFileSync(file, "utf8");
|
||||
@@ -31,34 +34,28 @@ for (const file of files) {
|
||||
}
|
||||
|
||||
function placeholders(s) {
|
||||
return [...s.matchAll(/\{(\w+)\}/g)]
|
||||
.map((m) => m[1])
|
||||
.sort()
|
||||
.join(",");
|
||||
return [...s.matchAll(/\{(\w+)\}/g)].map((m) => m[1]).sort().join(",");
|
||||
}
|
||||
|
||||
const missing = [];
|
||||
const mismatch = [];
|
||||
for (const [key, file] of calls) {
|
||||
if (!Object.prototype.hasOwnProperty.call(dict, key)) {
|
||||
missing.push(`${file}: ${JSON.stringify(key)}`);
|
||||
continue;
|
||||
}
|
||||
if (placeholders(dict[key]) !== placeholders(key)) {
|
||||
mismatch.push(`${JSON.stringify(key)}: source {${placeholders(key)}} dict {${placeholders(dict[key])}}`);
|
||||
const allKeys = new Set(dictionaries.flatMap(([, dict]) => Object.keys(dict)));
|
||||
const errors = [];
|
||||
if (!dictionaries.length) errors.push("No locale dictionaries found");
|
||||
for (const [name, dict] of dictionaries) {
|
||||
for (const key of new Set([...allKeys, ...calls.keys()])) {
|
||||
if (!Object.prototype.hasOwnProperty.call(dict, key)) {
|
||||
errors.push(`${name}: missing ${JSON.stringify(key)} (${calls.get(key) ?? "dictionary parity"})`);
|
||||
continue;
|
||||
}
|
||||
const value = dict[key];
|
||||
if (typeof value !== "string" || !value.trim()) {
|
||||
errors.push(`${name}: empty or non-string value for ${JSON.stringify(key)}`);
|
||||
} else if (placeholders(value) !== placeholders(key)) {
|
||||
errors.push(`${name}: placeholder mismatch for ${JSON.stringify(key)}`);
|
||||
}
|
||||
}
|
||||
console.log(`i18n: ${calls.size} literal keys checked against ${Object.keys(dict).length} ${name} entries`);
|
||||
}
|
||||
|
||||
if (missing.length || mismatch.length) {
|
||||
if (missing.length) {
|
||||
console.error(`Missing tr.json entries (${missing.length}):\n${missing.join("\n")}`);
|
||||
}
|
||||
if (mismatch.length) {
|
||||
console.error(`Placeholder mismatches (${mismatch.length}):\n${mismatch.join("\n")}`);
|
||||
}
|
||||
if (errors.length) {
|
||||
console.error(errors.join("\n"));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`i18n: ${calls.size} literal keys checked against ${Object.keys(dict).length} tr.json entries`,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import test from "node:test";
|
||||
import vm from "node:vm";
|
||||
import ts from "typescript";
|
||||
|
||||
const sourceURL = new URL("../src/i18n/index.ts", import.meta.url);
|
||||
const require = createRequire(sourceURL);
|
||||
const code = ts.transpileModule(readFileSync(sourceURL, "utf8"), {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, esModuleInterop: true },
|
||||
}).outputText;
|
||||
|
||||
function load({ saved = null, languages = ["en-US"], language = "en-US", blocked = false, server = false } = {}) {
|
||||
const writes = [];
|
||||
let reloads = 0;
|
||||
const context = { exports: {}, require };
|
||||
if (!server) {
|
||||
context.document = { documentElement: { lang: "en" } };
|
||||
context.window = {
|
||||
localStorage: {
|
||||
getItem(key) {
|
||||
assert.equal(key, "artex.locale");
|
||||
if (blocked) throw new Error("Storage blocked");
|
||||
return saved;
|
||||
},
|
||||
setItem(key, value) {
|
||||
if (blocked) throw new Error("Storage blocked");
|
||||
writes.push([key, value]);
|
||||
},
|
||||
},
|
||||
navigator: { languages, language },
|
||||
location: { reload: () => { reloads++; } },
|
||||
};
|
||||
}
|
||||
vm.runInNewContext(code, context, { filename: "i18n/index.js" });
|
||||
return { api: context.exports, document: context.document, writes, reloads: () => reloads };
|
||||
}
|
||||
|
||||
test("static export remains English and unknown keys fall back safely", () => {
|
||||
const { api } = load({ server: true });
|
||||
assert.equal(api.locale, "en");
|
||||
assert.equal(api.intlLocale, "en-US");
|
||||
assert.equal(api.t("Unknown {value}", { value: 3 }), "Unknown 3");
|
||||
});
|
||||
|
||||
test("saved Chinese preference wins and sets the document and Intl locale", () => {
|
||||
const { api, document } = load({ saved: "zh-CN", languages: ["tr-TR"] });
|
||||
assert.equal(api.locale, "zh-CN");
|
||||
assert.equal(api.intlLocale, "zh-CN");
|
||||
assert.equal(document.documentElement.lang, "zh-CN");
|
||||
assert.equal(api.t("Language"), "语言");
|
||||
assert.equal(api.t("{count} tasks", { count: 3 }), "3 个任务");
|
||||
assert.equal(api.t("Task #{id}"), "任务 #{id}");
|
||||
assert.equal(api.t("constructor"), "constructor");
|
||||
assert.equal(api.t("toString"), "toString");
|
||||
assert.equal(api.t("__proto__"), "__proto__");
|
||||
assert.equal(api.t("{count} tasks", Object.create({ count: 3 })), "{count} 个任务");
|
||||
});
|
||||
|
||||
test("Chinese browser tags, fallback languages, invalid preferences and blocked storage", () => {
|
||||
for (const tag of ["zh", "zh-CN", "zh-SG", "zh-Hans-CN", "ZH-cn"]) {
|
||||
assert.equal(load({ languages: [tag] }).api.locale, "zh-CN");
|
||||
}
|
||||
assert.equal(load({ saved: "invalid", languages: ["fr-FR", "zh-CN"] }).api.locale, "zh-CN");
|
||||
assert.equal(load({ blocked: true, languages: ["zh-CN"] }).api.locale, "zh-CN");
|
||||
assert.equal(load({ languages: null, language: "zh-CN" }).api.locale, "zh-CN");
|
||||
assert.equal(load({ languages: [], language: "zh-CN" }).api.locale, "en");
|
||||
assert.equal(load({ languages: ["fr-FR"] }).api.locale, "en");
|
||||
});
|
||||
|
||||
test("existing English and Turkish preferences and formatting are preserved", () => {
|
||||
const english = load({ saved: "en", languages: ["zh-CN"] }).api;
|
||||
const turkish = load({ saved: "tr", languages: ["zh-CN"] }).api;
|
||||
assert.equal(english.locale, "en");
|
||||
assert.equal(english.t("Language"), "Language");
|
||||
assert.equal(turkish.locale, "tr");
|
||||
assert.equal(turkish.intlLocale, "tr-TR");
|
||||
assert.equal(turkish.t("Language"), "Dil");
|
||||
assert.equal(load({ languages: ["tr-TR"] }).api.locale, "tr");
|
||||
});
|
||||
|
||||
test("switching persists the existing storage key and reloads once", () => {
|
||||
const state = load();
|
||||
state.api.setLocale("en");
|
||||
assert.equal(state.reloads(), 0);
|
||||
state.api.setLocale("zh-CN");
|
||||
assert.deepEqual(state.writes, [["artex.locale", "zh-CN"]]);
|
||||
assert.equal(state.reloads(), 1);
|
||||
const blocked = load({ blocked: true });
|
||||
assert.doesNotThrow(() => blocked.api.setLocale("zh-CN"));
|
||||
assert.equal(blocked.reloads(), 1);
|
||||
});
|
||||
@@ -20,7 +20,6 @@ import { usePreferencesStore } from "@/stores/preferences/preferences-provider";
|
||||
|
||||
import { NavMain } from "./nav-main";
|
||||
import { NavUser } from "./nav-user";
|
||||
import { SidebarSupportCard } from "./sidebar-support-card";
|
||||
|
||||
|
||||
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Ellipsis, Folder, Forward, type LucideIcon, Trash2 } from "lucide-react";
|
||||
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
SidebarGroup,
|
||||
SidebarGroupLabel,
|
||||
SidebarMenu,
|
||||
SidebarMenuAction,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
useSidebar,
|
||||
} from "@/components/ui/sidebar";
|
||||
import { t } from "@/i18n";
|
||||
|
||||
export function NavDocuments({
|
||||
items,
|
||||
}: {
|
||||
readonly items: readonly {
|
||||
readonly name: string;
|
||||
readonly url: string;
|
||||
readonly icon: LucideIcon;
|
||||
}[];
|
||||
}) {
|
||||
const { isMobile } = useSidebar();
|
||||
|
||||
return (
|
||||
<SidebarGroup className="group-data-[collapsible=icon]:hidden">
|
||||
<SidebarGroupLabel>{t("Documents")}</SidebarGroupLabel>
|
||||
<SidebarMenu>
|
||||
{items.map((item) => (
|
||||
<SidebarMenuItem key={item.name}>
|
||||
<SidebarMenuButton asChild>
|
||||
<a href={item.url}>
|
||||
<item.icon />
|
||||
<span>{item.name}</span>
|
||||
</a>
|
||||
</SidebarMenuButton>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<SidebarMenuAction showOnHover className="rounded-sm data-[state=open]:bg-accent">
|
||||
<Ellipsis />
|
||||
<span className="sr-only">{t("More")}</span>
|
||||
</SidebarMenuAction>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent
|
||||
className="w-24 rounded-lg"
|
||||
side={isMobile ? "bottom" : "right"}
|
||||
align={isMobile ? "end" : "start"}
|
||||
>
|
||||
<DropdownMenuItem>
|
||||
<Folder />
|
||||
<span>{t("Open")}</span>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>
|
||||
<Forward />
|
||||
<span>{t("Share")}</span>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem variant="destructive">
|
||||
<Trash2 />
|
||||
<span>{t("Delete")}</span>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</SidebarMenuItem>
|
||||
))}
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton className="text-sidebar-foreground/70">
|
||||
<Ellipsis className="text-sidebar-foreground/70" />
|
||||
<span>{t("More")}</span>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</SidebarGroup>
|
||||
);
|
||||
}
|
||||
@@ -4,10 +4,9 @@ import * as React from "react";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
import { ChevronRight, MailIcon, PlusCircleIcon } from "lucide-react";
|
||||
import { ChevronRight } from "lucide-react";
|
||||
import { api } from "@/lib/api";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||
import {
|
||||
DropdownMenu,
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import type * as React from "react";
|
||||
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
|
||||
import {
|
||||
SidebarGroup,
|
||||
SidebarGroupContent,
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
} from "@/components/ui/sidebar";
|
||||
|
||||
export function NavSecondary({
|
||||
items,
|
||||
...props
|
||||
}: {
|
||||
items: {
|
||||
title: string;
|
||||
url: string;
|
||||
icon: LucideIcon;
|
||||
}[];
|
||||
} & React.ComponentPropsWithoutRef<typeof SidebarGroup>) {
|
||||
return (
|
||||
<SidebarGroup {...props}>
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
{items.map((item) => (
|
||||
<SidebarMenuItem key={item.title}>
|
||||
<SidebarMenuButton asChild>
|
||||
<a href={item.url}>
|
||||
<item.icon />
|
||||
<span>{item.title}</span>
|
||||
</a>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
))}
|
||||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
</SidebarGroup>
|
||||
);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import Link from "next/link";
|
||||
|
||||
import { siX } from "simple-icons";
|
||||
|
||||
import { SimpleIcon } from "@/components/simple-icon";
|
||||
import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { t } from "@/i18n";
|
||||
|
||||
export function SidebarSupportCard() {
|
||||
// The X link sits inside the sentence through a placeholder so the word order can follow the locale.
|
||||
const [before, after = ""] = t("Open an issue or do reach out to me on {x}.").split("{x}");
|
||||
return (
|
||||
<Card size="sm" className="overflow-hidden shadow-none group-data-[collapsible=icon]:hidden">
|
||||
<CardHeader className="min-w-0 px-4">
|
||||
<CardTitle className="truncate text-sm">{t("Looking for something more?")}</CardTitle>
|
||||
<CardDescription className="line-clamp-2">
|
||||
{before.trimEnd()}
|
||||
<Link
|
||||
href="https://x.com/arhamkhnz"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
aria-label={t("Reach out on X")}
|
||||
className="inline-flex items-center text-foreground"
|
||||
>
|
||||
<SimpleIcon icon={siX} aria-hidden className="size-3 fill-current" />
|
||||
</Link>
|
||||
{after}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -14,11 +14,11 @@ import {
|
||||
TargetIcon,
|
||||
ZapIcon,
|
||||
} from "lucide-react";
|
||||
import { Bar, BarChart, CartesianGrid, Tooltip as RechartsTooltip, XAxis, YAxis } from "recharts";
|
||||
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts";
|
||||
|
||||
import { StatusBadge } from "@/components/status-badge";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||
import { type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { api } from "@/lib/api";
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
/* Theme preset styles: these override CSS variables based on the selected data-theme-preset */
|
||||
@import "../styles/presets/brutalist.css";
|
||||
@import "../styles/presets/neon.css";
|
||||
@import "../styles/presets/soft-pop.css";
|
||||
@import "../styles/presets/tangerine.css";
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import * as React from "react";
|
||||
import { toast } from "sonner";
|
||||
import { EyeIcon, GitCompareIcon, InfoIcon, PencilIcon, RotateCcwIcon, SaveIcon, Trash2Icon, XIcon } from "lucide-react";
|
||||
import { EyeIcon, GitCompareIcon, PencilIcon, RotateCcwIcon, SaveIcon, Trash2Icon, XIcon } from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
import { PlusIcon, Trash2Icon } from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
@@ -1,497 +0,0 @@
|
||||
import FullCalendar, { type CalendarOptions, type DayCellInfo } from '@fullcalendar/react'
|
||||
import '@fullcalendar/react/skeleton.css'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const xxsTextClass = 'text-[0.6875rem]/[1.090909]'
|
||||
|
||||
const blockPointerResizerClass = 'absolute hidden group-hover:block'
|
||||
const rowPointerResizerClass = `${blockPointerResizerClass} inset-y-0 w-2`
|
||||
const columnPointerResizerClass = `${blockPointerResizerClass} inset-x-0 h-2`
|
||||
|
||||
const blockTouchResizerClass = 'absolute size-2 border border-(--fc-event-color) bg-background rounded-full'
|
||||
const rowTouchResizerClass = `${blockTouchResizerClass} top-1/2 -mt-1`
|
||||
const columnTouchResizerClass = `${blockTouchResizerClass} left-1/2 -ml-1`
|
||||
|
||||
const tallDayCellBottomClass = 'min-h-3'
|
||||
const getShortDayCellBottomClass = (info: DayCellInfo) => cn(
|
||||
!info.isNarrow && 'min-h-0.5'
|
||||
)
|
||||
|
||||
const dayRowCommonClasses: CalendarOptions = {
|
||||
|
||||
/* Day Row > List-Item Event
|
||||
----------------------------------------------------------------------------------------------- */
|
||||
|
||||
listItemEventClass: (info) => cn(
|
||||
'mb-px p-px rounded-sm',
|
||||
info.isNarrow ? 'mx-0.5' : 'mx-1',
|
||||
info.isSelected
|
||||
? 'bg-foreground/5'
|
||||
: 'hover:bg-foreground/5',
|
||||
),
|
||||
listItemEventInnerClass: (info) => cn(
|
||||
'flex flex-row items-center justify-between',
|
||||
info.isNarrow
|
||||
? `py-px ${xxsTextClass}`
|
||||
: 'py-0.5 text-xs',
|
||||
),
|
||||
listItemEventTimeClass: (info) => cn(
|
||||
info.isNarrow ? 'px-px' : 'px-0.5',
|
||||
'order-1 whitespace-nowrap overflow-hidden shrink-1',
|
||||
),
|
||||
listItemEventTitleClass: (info) => cn(
|
||||
info.isNarrow ? 'px-px' : 'px-0.5',
|
||||
'font-medium whitespace-nowrap overflow-hidden shrink-100',
|
||||
info.timeText && 'text-ellipsis',
|
||||
),
|
||||
|
||||
/* Day Row > Row Event
|
||||
----------------------------------------------------------------------------------------------- */
|
||||
|
||||
rowEventClass: (info) => cn(
|
||||
info.isStart && (info.isNarrow ? 'ms-0.5' : 'ms-1'),
|
||||
info.isEnd && (info.isNarrow ? 'me-0.5' : 'me-1'),
|
||||
),
|
||||
rowEventInnerClass: (info) => cn(info.isNarrow ? 'py-px' : 'py-0.5'),
|
||||
|
||||
/* Day Row > More-Link
|
||||
----------------------------------------------------------------------------------------------- */
|
||||
|
||||
rowMoreLinkClass: (info) => cn(
|
||||
'mb-px border rounded-sm',
|
||||
info.isNarrow
|
||||
? 'mx-0.5 border-primary hover:bg-foreground/5'
|
||||
: 'self-start mx-1 border-transparent bg-foreground/5 hover:bg-foreground/10',
|
||||
),
|
||||
rowMoreLinkInnerClass: (info) => cn(
|
||||
info.isNarrow
|
||||
? `p-px ${xxsTextClass}`
|
||||
: 'p-0.5 text-xs',
|
||||
),
|
||||
}
|
||||
|
||||
export type EventCalendarViewProps =
|
||||
CalendarOptions &
|
||||
Required<Pick<CalendarOptions, 'popoverCloseContent'>> // ensure callers define icons
|
||||
|
||||
export function EventCalendarViews({
|
||||
height,
|
||||
views: userViews,
|
||||
...restOptions
|
||||
}: EventCalendarViewProps) {
|
||||
return (
|
||||
<FullCalendar
|
||||
height={height}
|
||||
|
||||
/* Abstract Event
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
eventShortHeight={50}
|
||||
eventColor='var(--primary)'
|
||||
eventContrastColor='var(--primary-foreground)'
|
||||
eventClass={(info) => cn(
|
||||
info.isSelected
|
||||
? ['outline-3', info.isDragging && 'shadow-lg']
|
||||
: 'focus-visible:outline-3',
|
||||
'outline-ring/50',
|
||||
)}
|
||||
|
||||
/* Background Event
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
backgroundEventColor='var(--chart-3)'
|
||||
backgroundEventClass='not-print:bg-[color-mix(in_oklab,var(--fc-event-color)_10%,transparent)] print:border-1 print:border-(--fc-event-color)'
|
||||
backgroundEventTitleClass={(info) => cn(
|
||||
'opacity-50 italic',
|
||||
(info.isNarrow || info.isShort)
|
||||
? `p-1 ${xxsTextClass}`
|
||||
: 'p-2 text-xs',
|
||||
)}
|
||||
|
||||
/* List-Item Event
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
listItemEventTimeClass='text-muted-foreground'
|
||||
|
||||
/* Block Event
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
blockEventClass={(info) => cn(
|
||||
'group relative border-transparent print:border-(--fc-event-color) bg-(--fc-event-color) print:bg-white hover:bg-[color-mix(in_oklab,var(--fc-event-color)_92%,var(--fc-event-contrast-color))]',
|
||||
info.isInteractive && 'active:bg-[color-mix(in_oklab,var(--fc-event-color)_85%,var(--fc-event-contrast-color))]',
|
||||
(info.isDragging && !info.isSelected) && 'opacity-75',
|
||||
)}
|
||||
blockEventInnerClass='text-(--fc-event-contrast-color) print:text-black'
|
||||
blockEventTimeClass='whitespace-nowrap overflow-hidden shrink-1'
|
||||
blockEventTitleClass='whitespace-nowrap overflow-hidden shrink-100'
|
||||
|
||||
/* Row Event
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
rowEventClass={(info) => cn(
|
||||
'mb-px border-y',
|
||||
info.isStart && 'rounded-s-sm border-s',
|
||||
info.isEnd && 'rounded-e-sm border-e',
|
||||
)}
|
||||
rowEventBeforeClass={(info) => cn(
|
||||
info.isStartResizable && [
|
||||
info.isSelected ? rowTouchResizerClass : rowPointerResizerClass,
|
||||
'-start-1',
|
||||
]
|
||||
)}
|
||||
rowEventAfterClass={(info) => cn(
|
||||
info.isEndResizable && [
|
||||
info.isSelected ? rowTouchResizerClass : rowPointerResizerClass,
|
||||
'-end-1',
|
||||
]
|
||||
)}
|
||||
rowEventInnerClass={(info) => cn(
|
||||
'flex flex-row items-center',
|
||||
info.isNarrow ? xxsTextClass : 'text-xs',
|
||||
)}
|
||||
rowEventTimeClass={(info) => cn(
|
||||
info.isNarrow ? 'ps-0.5' : 'ps-1'
|
||||
)}
|
||||
rowEventTitleClass={(info) => cn(
|
||||
info.isNarrow ? 'px-0.5' : 'px-1',
|
||||
'font-medium',
|
||||
)}
|
||||
|
||||
/* Column Event
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
columnEventClass={(info) => cn(
|
||||
'border-x ring ring-background',
|
||||
info.isStart && ['border-t rounded-t-lg', info.isNarrow ? 'mt-px' : 'mt-0.5'],
|
||||
info.isEnd && ['border-b rounded-b-lg', info.isNarrow ? 'mb-px' : 'mb-0.5'],
|
||||
)}
|
||||
columnEventBeforeClass={(info) => cn(
|
||||
info.isStartResizable && [
|
||||
info.isSelected ? columnTouchResizerClass : columnPointerResizerClass,
|
||||
'-top-1',
|
||||
]
|
||||
)}
|
||||
columnEventAfterClass={(info) => cn(
|
||||
info.isEndResizable && [
|
||||
info.isSelected ? columnTouchResizerClass : columnPointerResizerClass,
|
||||
'-bottom-1',
|
||||
]
|
||||
)}
|
||||
columnEventInnerClass={(info) => cn(
|
||||
'flex',
|
||||
info.isShort
|
||||
? 'flex-row items-center gap-1 p-1'
|
||||
: ['flex-col', info.isNarrow ? 'px-1 py-0.5' : 'px-2 py-1'],
|
||||
(info.isNarrow || info.isShort) ? xxsTextClass : 'text-xs',
|
||||
)}
|
||||
columnEventTimeClass={(info) => cn(
|
||||
!info.isShort && (info.isNarrow ? 'pt-0.5' : 'pt-1')
|
||||
)}
|
||||
columnEventTitleClass={(info) => cn(
|
||||
!info.isShort && (info.isNarrow ? 'py-0.5' : 'py-1'),
|
||||
'font-medium',
|
||||
)}
|
||||
|
||||
/* More-Link
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
moreLinkClass="focus-visible:outline-3 outline-ring/50"
|
||||
moreLinkInnerClass='whitespace-nowrap overflow-hidden'
|
||||
columnMoreLinkClass="my-0.5 border border-transparent print:border-black rounded-md bg-[color-mix(in_oklab,var(--foreground)_10%,var(--background))] hover:bg-[color-mix(in_oklab,var(--foreground)_13%,var(--background))] print:bg-white ring ring-background"
|
||||
columnMoreLinkInnerClass={(info) => cn(
|
||||
info.isNarrow
|
||||
? `p-0.5 ${xxsTextClass}`
|
||||
: 'p-1 text-xs',
|
||||
)}
|
||||
|
||||
/* Day Header
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
dayHeaderClass={(info) => cn(
|
||||
'justify-center',
|
||||
info.inPopover ? 'border-b bg-foreground/5' :
|
||||
info.isMajor && 'border border-foreground/20',
|
||||
)}
|
||||
dayHeaderInnerClass={(info) => cn(
|
||||
'flex flex-row items-center',
|
||||
info.isNarrow ? 'text-xs' : 'text-sm',
|
||||
info.inPopover ? [
|
||||
'm-1.5 px-1 py-0.5 rounded-sm font-semibold',
|
||||
info.hasNavLink && 'hover:bg-foreground/5',
|
||||
] : !info.dayNumberText ? [
|
||||
'mx-0.5 my-1.5 py-0.5 px-1.5 rounded-sm text-muted-foreground',
|
||||
info.hasNavLink && 'hover:bg-foreground/5',
|
||||
] : !info.isToday ? [
|
||||
'mx-2 my-2.5 h-6 px-1.5 rounded-sm text-muted-foreground',
|
||||
info.hasNavLink && 'hover:bg-foreground/5',
|
||||
] : (
|
||||
'group mx-2 my-2 h-7 outline-none'
|
||||
)
|
||||
)}
|
||||
dayHeaderContent={(info) => (
|
||||
(info.inPopover || !info.dayNumberText || !info.isToday) ? (
|
||||
<>{info.text}</>
|
||||
) : (
|
||||
<>
|
||||
{info.textParts.map((textPart, i) => (
|
||||
<span
|
||||
key={i}
|
||||
className={cn(
|
||||
'whitespace-pre',
|
||||
(textPart.type === 'day' && info.isToday)
|
||||
? [
|
||||
'first:-ms-1 last:-me-1 size-7 rounded-full font-semibold flex flex-row items-center justify-center bg-chart-1/50',
|
||||
info.hasNavLink && 'group-hover:bg-chart-1/60 group-focus-visible:outline-3 outline-ring/50',
|
||||
]
|
||||
: 'text-muted-foreground',
|
||||
)}
|
||||
>{textPart.value}</span>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
)}
|
||||
|
||||
/* Day Cell
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
dayCellClass={(info) => cn(
|
||||
'border',
|
||||
info.isMajor && 'border-foreground/20',
|
||||
)}
|
||||
dayCellTopClass={(info) => cn(
|
||||
info.isNarrow ? 'min-h-0.5' : 'min-h-1',
|
||||
'flex flex-row justify-end',
|
||||
)}
|
||||
dayCellTopInnerClass={(info) => cn(
|
||||
'flex flex-row items-center',
|
||||
info.isNarrow
|
||||
? `my-px h-5 ${xxsTextClass}`
|
||||
: 'my-1 h-6 text-sm',
|
||||
!info.isToday
|
||||
? [
|
||||
'rounded-s-sm whitespace-nowrap',
|
||||
!info.isOther && 'font-semibold',
|
||||
info.isNarrow ? 'px-1' : 'px-2',
|
||||
!info.monthText && 'text-muted-foreground',
|
||||
info.hasNavLink && 'hover:bg-foreground/5',
|
||||
]
|
||||
: [
|
||||
'group outline-none',
|
||||
info.isNarrow
|
||||
? 'mx-px'
|
||||
: 'mx-2',
|
||||
]
|
||||
)}
|
||||
dayCellTopContent={(info) => (
|
||||
!info.isToday ? (
|
||||
<>{info.text}</>
|
||||
) : (
|
||||
<>
|
||||
{info.textParts.map((textPart, i) => (
|
||||
<span
|
||||
key={i}
|
||||
className={cn(
|
||||
'whitespace-pre',
|
||||
(textPart.type === 'day' && info.isToday)
|
||||
? [
|
||||
'rounded-full font-semibold flex flex-row items-center justify-center bg-chart-1/50',
|
||||
info.hasNavLink && 'group-hover:bg-chart-1/60 group-focus-visible:outline-3 outline-ring/50',
|
||||
info.isNarrow
|
||||
? 'size-5'
|
||||
: 'size-6 first:-ms-1 last:-me-1',
|
||||
]
|
||||
: (!info.monthText && 'text-muted-foreground'),
|
||||
)}
|
||||
>{textPart.value}</span>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
)}
|
||||
dayCellInnerClass={(info) => cn(info.inPopover && 'p-2')}
|
||||
|
||||
/* Popover
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
popoverClass='border rounded-md overflow-hidden shadow-lg m-1 bg-popover text-popover-foreground min-w-55'
|
||||
popoverCloseClass="group absolute top-1.5 end-1.5 p-0.5 rounded-sm hover:bg-foreground/5 focus-visible:outline-3 outline-ring/50"
|
||||
|
||||
/* Lane
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
dayLaneClass={(info) => cn(
|
||||
'border',
|
||||
info.isMajor && 'border-foreground/20',
|
||||
info.isDisabled && 'bg-foreground/3',
|
||||
)}
|
||||
dayLaneInnerClass={(info) => (
|
||||
info.isStack
|
||||
? 'm-1'
|
||||
: info.isNarrow ? 'mx-px' : 'mx-0.5'
|
||||
)}
|
||||
slotLaneClass={(info) => cn(
|
||||
'border',
|
||||
info.isMinor && 'border-dotted',
|
||||
)}
|
||||
|
||||
/* List Day
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
listDayClass={(info) => cn(
|
||||
'flex flex-col',
|
||||
!info.isLast && 'border-b',
|
||||
)}
|
||||
listDayHeaderClass="-mb-px border-b bg-[color-mix(in_oklab,var(--foreground)_3%,var(--background))] flex flex-row items-center justify-between"
|
||||
listDayHeaderInnerClass={(info) => cn(
|
||||
'm-1.5 px-1.5 py-0.5 rounded-sm text-sm',
|
||||
!info.level && 'font-semibold',
|
||||
(!info.level && info.isToday)
|
||||
? [
|
||||
'bg-chart-1/50',
|
||||
info.hasNavLink && 'hover:bg-chart-1/60 focus-visible:outline-3 outline-ring/50',
|
||||
]
|
||||
: info.hasNavLink && 'hover:bg-foreground/5',
|
||||
)}
|
||||
listDayBodyClass='mt-px px-1.5 py-2 gap-2'
|
||||
|
||||
/* Single Month (in Multi-Month)
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
singleMonthClass={(info) => cn(
|
||||
info.multiMonthColumns > 1 && 'm-3',
|
||||
(info.multiMonthColumns === 1 && !info.isLast) && 'border-b',
|
||||
)}
|
||||
singleMonthHeaderClass={(info) => cn(
|
||||
info.multiMonthColumns > 1 ? 'pb-2' : 'py-1 border-b bg-background',
|
||||
'items-center',
|
||||
)}
|
||||
singleMonthHeaderInnerClass={(info) => cn(
|
||||
'px-1.5 py-0.5 rounded-sm text-base font-semibold',
|
||||
info.hasNavLink && 'hover:bg-foreground/5',
|
||||
)}
|
||||
|
||||
/* Misc Table
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
tableBodyClass='bg-background'
|
||||
fillerClass='border opacity-50'
|
||||
dayNarrowWidth={100}
|
||||
dayHeaderRowClass='border'
|
||||
dayRowClass='border'
|
||||
slotHeaderRowClass='border'
|
||||
slotHeaderInnerClass='text-muted-foreground'
|
||||
|
||||
/* Misc Content
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
navLinkClass="focus-visible:outline-3 outline-ring/50"
|
||||
inlineWeekNumberClass={(info) => cn(
|
||||
'absolute start-0 whitespace-nowrap rounded-e-sm text-muted-foreground',
|
||||
info.isNarrow
|
||||
? `top-0.5 my-px p-0.5 ${xxsTextClass}`
|
||||
: 'top-1 p-1 text-xs',
|
||||
info.hasNavLink && 'hover:bg-foreground/5',
|
||||
)}
|
||||
highlightClass='bg-chart-1/20'
|
||||
nonBusinessHoursClass='bg-foreground/3'
|
||||
nowIndicatorLineClass='-m-px border-1 border-destructive'
|
||||
nowIndicatorDotClass="-m-[6px] border-6 border-destructive size-0 rounded-full ring-2 ring-background"
|
||||
|
||||
/* View-Specific Options
|
||||
----------------------------------------------------------------------------------------- */
|
||||
|
||||
views={{
|
||||
...userViews,
|
||||
dayGrid: {
|
||||
...dayRowCommonClasses,
|
||||
tableHeaderClass: 'bg-background',
|
||||
dayHeaderAlign: (info) => info.inPopover ? 'start' : info.isNarrow ? 'center' : 'end',
|
||||
dayHeaderDividerClass: 'border-b',
|
||||
dayCellBottomClass: getShortDayCellBottomClass,
|
||||
...userViews?.dayGrid,
|
||||
},
|
||||
multiMonth: {
|
||||
...dayRowCommonClasses,
|
||||
className: 'bg-foreground/3',
|
||||
tableHeaderClass: (info) => cn(info.multiMonthColumns === 1 && 'bg-background'),
|
||||
dayHeaderAlign: (info) => info.inPopover ? 'start' : info.isNarrow ? 'center' : 'end',
|
||||
dayHeaderDividerClass: (info) => cn(info.multiMonthColumns === 1 && 'border-b'),
|
||||
dayCellBottomClass: getShortDayCellBottomClass,
|
||||
tableBodyClass: (info) => cn(info.multiMonthColumns > 1 && 'border rounded-sm overflow-hidden'),
|
||||
...userViews?.multiMonth,
|
||||
},
|
||||
timeGrid: {
|
||||
...dayRowCommonClasses,
|
||||
tableHeaderClass: 'bg-background',
|
||||
dayHeaderAlign: (info) => info.inPopover ? 'start' : 'center',
|
||||
dayHeaderDividerClass: (info) => cn(
|
||||
'border-b',
|
||||
!info.options.allDaySlot && 'border-foreground/20 not-print:shadow-sm',
|
||||
),
|
||||
dayCellBottomClass: tallDayCellBottomClass,
|
||||
|
||||
/* TimeGrid > Week Number Header
|
||||
------------------------------------------------------------------------------------- */
|
||||
|
||||
weekNumberHeaderClass: 'items-center justify-end',
|
||||
weekNumberHeaderInnerClass: (info) => cn(
|
||||
'mx-0.5 h-6 px-1.5 text-muted-foreground flex flex-row items-center rounded-sm',
|
||||
info.isNarrow ? 'text-xs' : 'text-sm',
|
||||
info.hasNavLink && 'hover:bg-foreground/5',
|
||||
),
|
||||
|
||||
/* TimeGrid > All-Day Header
|
||||
------------------------------------------------------------------------------------- */
|
||||
|
||||
allDayHeaderClass: 'items-center',
|
||||
allDayHeaderInnerClass: (info) => cn(
|
||||
'm-2 text-muted-foreground',
|
||||
info.isNarrow ? xxsTextClass : 'text-xs',
|
||||
),
|
||||
allDayDividerClass: 'border-b border-foreground/20 not-print:shadow-sm',
|
||||
|
||||
/* TimeGrid > Slot Header
|
||||
------------------------------------------------------------------------------------- */
|
||||
|
||||
slotHeaderClass: 'justify-end',
|
||||
slotHeaderInnerClass: (info) => cn(
|
||||
'relative m-2',
|
||||
info.isNarrow
|
||||
? `-top-3.5 ${xxsTextClass}`
|
||||
: '-top-4 text-xs',
|
||||
info.isFirst && 'hidden',
|
||||
),
|
||||
slotHeaderDividerClass: 'border-e',
|
||||
|
||||
...userViews?.timeGrid,
|
||||
},
|
||||
list: {
|
||||
|
||||
/* List-View > List-Item Event
|
||||
------------------------------------------------------------------------------------- */
|
||||
|
||||
listItemEventClass: (info) => cn(
|
||||
'group py-1 rounded-sm hover:bg-muted/50',
|
||||
info.isInteractive && 'focus-visible:bg-muted/50 -outline-offset-3',
|
||||
),
|
||||
listItemEventBeforeClass: 'w-1.5 bg-(--fc-event-color) rounded-full',
|
||||
listItemEventInnerClass: '[display:contents]',
|
||||
listItemEventTimeClass: "-order-1 shrink-0 w-1/2 max-w-60 px-4 py-2 whitespace-nowrap overflow-hidden text-ellipsis text-sm",
|
||||
listItemEventTitleClass: (info) => cn(
|
||||
'grow min-w-0 px-4 py-2 whitespace-nowrap overflow-hidden text-sm',
|
||||
info.event.url && 'group-hover:underline',
|
||||
),
|
||||
|
||||
/* No-Events Screen
|
||||
------------------------------------------------------------------------------------- */
|
||||
|
||||
noEventsClass: 'grow flex flex-col items-center justify-center',
|
||||
noEventsInnerClass: 'py-15 text-muted-foreground',
|
||||
|
||||
...userViews?.list,
|
||||
},
|
||||
}}
|
||||
|
||||
{...restOptions}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
import { subDays } from "date-fns";
|
||||
import type { DateRange } from "react-day-picker";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Calendar } from "@/components/ui/calendar";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { intlLocale, t } from "@/i18n";
|
||||
|
||||
const fmtDate = (d: Date) => d.toLocaleDateString(intlLocale, { day: "numeric", month: "short", year: "numeric" });
|
||||
|
||||
interface DateRangePickerProps {
|
||||
value?: DateRange;
|
||||
onChange?: (value: DateRange | undefined) => void;
|
||||
}
|
||||
|
||||
export function DateRangePicker({ value, onChange }: DateRangePickerProps) {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const [internalDateRange, setInternalDateRange] = React.useState<DateRange | undefined>(() => {
|
||||
const to = new Date();
|
||||
const from = subDays(to, 29);
|
||||
return { from, to };
|
||||
});
|
||||
const dateRange = value ?? internalDateRange;
|
||||
let dateRangeLabel = t("Select date");
|
||||
|
||||
if (dateRange?.from) {
|
||||
dateRangeLabel = fmtDate(dateRange.from);
|
||||
}
|
||||
|
||||
if (dateRange?.from && dateRange.to) {
|
||||
dateRangeLabel = `${fmtDate(dateRange.from)} - ${fmtDate(dateRange.to)}`;
|
||||
}
|
||||
|
||||
const handleDateChange = (nextValue: DateRange | undefined) => {
|
||||
if (!value) {
|
||||
setInternalDateRange(nextValue);
|
||||
}
|
||||
onChange?.(nextValue);
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button variant="outline" id="date" className="font-normal">
|
||||
{dateRangeLabel}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-auto overflow-hidden p-0" align="end">
|
||||
<Calendar
|
||||
mode="range"
|
||||
defaultMonth={dateRange?.from}
|
||||
selected={dateRange}
|
||||
onSelect={handleDateChange}
|
||||
numberOfMonths={2}
|
||||
/>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import ReactMarkdown, { type Components } from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import type * as React from "react";
|
||||
|
||||
import type { SimpleIcon as SimpleIconType } from "simple-icons";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type SimpleIconProps = {
|
||||
icon: SimpleIconType;
|
||||
className?: string;
|
||||
} & React.SVGProps<SVGSVGElement>;
|
||||
|
||||
export function SimpleIcon({ icon, className, ...props }: SimpleIconProps) {
|
||||
const { title, path } = icon;
|
||||
|
||||
return (
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
aria-label={title}
|
||||
aria-hidden="false"
|
||||
focusable="false"
|
||||
className={cn("size-5 fill-foreground", className)}
|
||||
{...props}
|
||||
>
|
||||
<title>{title}</title>
|
||||
<path d={path} />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import {
|
||||
DayPicker,
|
||||
getDefaultClassNames,
|
||||
type DayButton,
|
||||
type Locale,
|
||||
} from "react-day-picker"
|
||||
|
||||
import { tr as dayPickerTr } from "react-day-picker/locale/tr"
|
||||
|
||||
import { locale as uiLocale } from "@/i18n"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Button, buttonVariants } from "@/components/ui/button"
|
||||
import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react"
|
||||
|
||||
function Calendar({
|
||||
className,
|
||||
classNames,
|
||||
showOutsideDays = true,
|
||||
captionLayout = "label",
|
||||
buttonVariant = "ghost",
|
||||
// Follow the UI language for month/weekday captions unless the caller passes its own locale.
|
||||
locale = uiLocale === "tr" ? dayPickerTr : undefined,
|
||||
formatters,
|
||||
components,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayPicker> & {
|
||||
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
|
||||
}) {
|
||||
const defaultClassNames = getDefaultClassNames()
|
||||
|
||||
return (
|
||||
<DayPicker
|
||||
showOutsideDays={showOutsideDays}
|
||||
className={cn(
|
||||
"group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(7)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent",
|
||||
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
||||
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
||||
className
|
||||
)}
|
||||
captionLayout={captionLayout}
|
||||
locale={locale}
|
||||
formatters={{
|
||||
formatMonthDropdown: (date) =>
|
||||
date.toLocaleString(locale?.code, { month: "short" }),
|
||||
...formatters,
|
||||
}}
|
||||
classNames={{
|
||||
root: cn("w-fit", defaultClassNames.root),
|
||||
months: cn(
|
||||
"relative flex flex-col gap-4 md:flex-row",
|
||||
defaultClassNames.months
|
||||
),
|
||||
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
||||
nav: cn(
|
||||
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
||||
defaultClassNames.nav
|
||||
),
|
||||
button_previous: cn(
|
||||
buttonVariants({ variant: buttonVariant }),
|
||||
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
||||
defaultClassNames.button_previous
|
||||
),
|
||||
button_next: cn(
|
||||
buttonVariants({ variant: buttonVariant }),
|
||||
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
||||
defaultClassNames.button_next
|
||||
),
|
||||
month_caption: cn(
|
||||
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
||||
defaultClassNames.month_caption
|
||||
),
|
||||
dropdowns: cn(
|
||||
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
||||
defaultClassNames.dropdowns
|
||||
),
|
||||
dropdown_root: cn(
|
||||
"relative rounded-(--cell-radius)",
|
||||
defaultClassNames.dropdown_root
|
||||
),
|
||||
dropdown: cn(
|
||||
"absolute inset-0 bg-popover opacity-0",
|
||||
defaultClassNames.dropdown
|
||||
),
|
||||
caption_label: cn(
|
||||
"font-medium select-none",
|
||||
captionLayout === "label"
|
||||
? "text-sm"
|
||||
: "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
||||
defaultClassNames.caption_label
|
||||
),
|
||||
month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
|
||||
weekdays: cn("flex", defaultClassNames.weekdays),
|
||||
weekday: cn(
|
||||
"flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
|
||||
defaultClassNames.weekday
|
||||
),
|
||||
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
||||
week_number_header: cn(
|
||||
"w-(--cell-size) select-none",
|
||||
defaultClassNames.week_number_header
|
||||
),
|
||||
week_number: cn(
|
||||
"text-[0.8rem] text-muted-foreground select-none",
|
||||
defaultClassNames.week_number
|
||||
),
|
||||
day: cn(
|
||||
"group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)",
|
||||
props.showWeekNumber
|
||||
? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)"
|
||||
: "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
|
||||
defaultClassNames.day
|
||||
),
|
||||
range_start: cn(
|
||||
"relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted",
|
||||
defaultClassNames.range_start
|
||||
),
|
||||
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
||||
range_end: cn(
|
||||
"relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted",
|
||||
defaultClassNames.range_end
|
||||
),
|
||||
today: cn(
|
||||
"rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none",
|
||||
defaultClassNames.today
|
||||
),
|
||||
outside: cn(
|
||||
"text-muted-foreground aria-selected:text-muted-foreground",
|
||||
defaultClassNames.outside
|
||||
),
|
||||
disabled: cn(
|
||||
"text-muted-foreground opacity-50",
|
||||
defaultClassNames.disabled
|
||||
),
|
||||
hidden: cn("invisible", defaultClassNames.hidden),
|
||||
...classNames,
|
||||
}}
|
||||
components={{
|
||||
Root: ({ className, rootRef, ...props }) => {
|
||||
return (
|
||||
<div
|
||||
data-slot="calendar"
|
||||
ref={rootRef}
|
||||
className={cn(className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
},
|
||||
Chevron: ({ className, orientation, ...props }) => {
|
||||
if (orientation === "left") {
|
||||
return (
|
||||
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
if (orientation === "right") {
|
||||
return (
|
||||
<ChevronRightIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<ChevronDownIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
},
|
||||
DayButton: ({ ...props }) => (
|
||||
<CalendarDayButton locale={locale} {...props} />
|
||||
),
|
||||
WeekNumber: ({ children, ...props }) => {
|
||||
return (
|
||||
<td {...props}>
|
||||
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
||||
{children}
|
||||
</div>
|
||||
</td>
|
||||
)
|
||||
},
|
||||
...components,
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CalendarDayButton({
|
||||
className,
|
||||
day,
|
||||
modifiers,
|
||||
locale,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {
|
||||
const defaultClassNames = getDefaultClassNames()
|
||||
|
||||
const ref = React.useRef<HTMLButtonElement>(null)
|
||||
React.useEffect(() => {
|
||||
if (modifiers.focused) ref.current?.focus()
|
||||
}, [modifiers.focused])
|
||||
|
||||
return (
|
||||
<Button
|
||||
ref={ref}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
data-day={day.date.toLocaleDateString(locale?.code)}
|
||||
data-selected-single={
|
||||
modifiers.selected &&
|
||||
!modifiers.range_start &&
|
||||
!modifiers.range_end &&
|
||||
!modifiers.range_middle
|
||||
}
|
||||
data-range-start={modifiers.range_start}
|
||||
data-range-end={modifiers.range_end}
|
||||
data-range-middle={modifiers.range_middle}
|
||||
className={cn(
|
||||
"relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70",
|
||||
defaultClassNames.day,
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Calendar, CalendarDayButton }
|
||||
@@ -1,243 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import useEmblaCarousel, {
|
||||
type UseEmblaCarouselType,
|
||||
} from "embla-carousel-react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { t } from "@/i18n"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
|
||||
|
||||
type CarouselApi = UseEmblaCarouselType[1]
|
||||
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
||||
type CarouselOptions = UseCarouselParameters[0]
|
||||
type CarouselPlugin = UseCarouselParameters[1]
|
||||
|
||||
type CarouselProps = {
|
||||
opts?: CarouselOptions
|
||||
plugins?: CarouselPlugin
|
||||
orientation?: "horizontal" | "vertical"
|
||||
setApi?: (api: CarouselApi) => void
|
||||
}
|
||||
|
||||
type CarouselContextProps = {
|
||||
carouselRef: ReturnType<typeof useEmblaCarousel>[0]
|
||||
api: ReturnType<typeof useEmblaCarousel>[1]
|
||||
scrollPrev: () => void
|
||||
scrollNext: () => void
|
||||
canScrollPrev: boolean
|
||||
canScrollNext: boolean
|
||||
} & CarouselProps
|
||||
|
||||
const CarouselContext = React.createContext<CarouselContextProps | null>(null)
|
||||
|
||||
function useCarousel() {
|
||||
const context = React.useContext(CarouselContext)
|
||||
|
||||
if (!context) {
|
||||
throw new Error("useCarousel must be used within a <Carousel />")
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
function Carousel({
|
||||
orientation = "horizontal",
|
||||
opts,
|
||||
setApi,
|
||||
plugins,
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & CarouselProps) {
|
||||
const [carouselRef, api] = useEmblaCarousel(
|
||||
{
|
||||
...opts,
|
||||
axis: orientation === "horizontal" ? "x" : "y",
|
||||
},
|
||||
plugins
|
||||
)
|
||||
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
||||
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
||||
|
||||
const onSelect = React.useCallback((api: CarouselApi) => {
|
||||
if (!api) return
|
||||
setCanScrollPrev(api.canScrollPrev())
|
||||
setCanScrollNext(api.canScrollNext())
|
||||
}, [])
|
||||
|
||||
const scrollPrev = React.useCallback(() => {
|
||||
api?.scrollPrev()
|
||||
}, [api])
|
||||
|
||||
const scrollNext = React.useCallback(() => {
|
||||
api?.scrollNext()
|
||||
}, [api])
|
||||
|
||||
const handleKeyDown = React.useCallback(
|
||||
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
||||
if (event.key === "ArrowLeft") {
|
||||
event.preventDefault()
|
||||
scrollPrev()
|
||||
} else if (event.key === "ArrowRight") {
|
||||
event.preventDefault()
|
||||
scrollNext()
|
||||
}
|
||||
},
|
||||
[scrollPrev, scrollNext]
|
||||
)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!api || !setApi) return
|
||||
setApi(api)
|
||||
}, [api, setApi])
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!api) return
|
||||
onSelect(api)
|
||||
api.on("reInit", onSelect)
|
||||
api.on("select", onSelect)
|
||||
|
||||
return () => {
|
||||
api?.off("select", onSelect)
|
||||
}
|
||||
}, [api, onSelect])
|
||||
|
||||
return (
|
||||
<CarouselContext.Provider
|
||||
value={{
|
||||
carouselRef,
|
||||
api: api,
|
||||
opts,
|
||||
orientation:
|
||||
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
||||
scrollPrev,
|
||||
scrollNext,
|
||||
canScrollPrev,
|
||||
canScrollNext,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
onKeyDownCapture={handleKeyDown}
|
||||
className={cn("relative", className)}
|
||||
role="region"
|
||||
aria-roledescription="carousel"
|
||||
data-slot="carousel"
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</CarouselContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||
const { carouselRef, orientation } = useCarousel()
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={carouselRef}
|
||||
className="overflow-hidden"
|
||||
data-slot="carousel-content"
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"flex",
|
||||
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
|
||||
const { orientation } = useCarousel()
|
||||
|
||||
return (
|
||||
<div
|
||||
role="group"
|
||||
aria-roledescription="slide"
|
||||
data-slot="carousel-item"
|
||||
className={cn(
|
||||
"min-w-0 shrink-0 grow-0 basis-full",
|
||||
orientation === "horizontal" ? "pl-4" : "pt-4",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CarouselPrevious({
|
||||
className,
|
||||
variant = "outline",
|
||||
size = "icon-sm",
|
||||
...props
|
||||
}: React.ComponentProps<typeof Button>) {
|
||||
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
||||
|
||||
return (
|
||||
<Button
|
||||
data-slot="carousel-previous"
|
||||
variant={variant}
|
||||
size={size}
|
||||
className={cn(
|
||||
"absolute touch-manipulation rounded-full",
|
||||
orientation === "horizontal"
|
||||
? "inset-y-0 -left-12 my-auto"
|
||||
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
||||
className
|
||||
)}
|
||||
disabled={!canScrollPrev}
|
||||
onClick={scrollPrev}
|
||||
{...props}
|
||||
>
|
||||
<ChevronLeftIcon />
|
||||
<span className="sr-only">{t("Previous slide")}</span>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
function CarouselNext({
|
||||
className,
|
||||
variant = "outline",
|
||||
size = "icon-sm",
|
||||
...props
|
||||
}: React.ComponentProps<typeof Button>) {
|
||||
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
||||
|
||||
return (
|
||||
<Button
|
||||
data-slot="carousel-next"
|
||||
variant={variant}
|
||||
size={size}
|
||||
className={cn(
|
||||
"absolute touch-manipulation rounded-full",
|
||||
orientation === "horizontal"
|
||||
? "inset-y-0 -right-12 my-auto"
|
||||
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
||||
className
|
||||
)}
|
||||
disabled={!canScrollNext}
|
||||
onClick={scrollNext}
|
||||
{...props}
|
||||
>
|
||||
<ChevronRightIcon />
|
||||
<span className="sr-only">{t("Next slide")}</span>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
type CarouselApi,
|
||||
Carousel,
|
||||
CarouselContent,
|
||||
CarouselItem,
|
||||
CarouselPrevious,
|
||||
CarouselNext,
|
||||
useCarousel,
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { OTPInput, OTPInputContext } from "input-otp"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { MinusIcon } from "lucide-react"
|
||||
|
||||
function InputOTP({
|
||||
className,
|
||||
containerClassName,
|
||||
...props
|
||||
}: React.ComponentProps<typeof OTPInput> & {
|
||||
containerClassName?: string
|
||||
}) {
|
||||
return (
|
||||
<OTPInput
|
||||
data-slot="input-otp"
|
||||
containerClassName={cn(
|
||||
"cn-input-otp flex items-center has-disabled:opacity-50",
|
||||
containerClassName
|
||||
)}
|
||||
spellCheck={false}
|
||||
className={cn("disabled:cursor-not-allowed", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function InputOTPGroup({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="input-otp-group"
|
||||
className={cn(
|
||||
"flex items-center rounded-lg has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function InputOTPSlot({
|
||||
index,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & {
|
||||
index: number
|
||||
}) {
|
||||
const inputOTPContext = React.useContext(OTPInputContext)
|
||||
const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {}
|
||||
|
||||
return (
|
||||
<div
|
||||
data-slot="input-otp-slot"
|
||||
data-active={isActive}
|
||||
className={cn(
|
||||
"relative flex size-8 items-center justify-center border-y border-r border-input text-sm transition-all outline-none first:rounded-l-lg first:border-l last:rounded-r-lg aria-invalid:border-destructive data-[active=true]:z-10 data-[active=true]:border-ring data-[active=true]:ring-3 data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:border-destructive data-[active=true]:aria-invalid:ring-destructive/20 dark:bg-input/30 dark:data-[active=true]:aria-invalid:ring-destructive/40",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{char}
|
||||
{hasFakeCaret && (
|
||||
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
||||
<div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function InputOTPSeparator({ ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="input-otp-separator"
|
||||
className="flex items-center [&_svg:not([class*='size-'])]:size-4"
|
||||
role="separator"
|
||||
{...props}
|
||||
>
|
||||
<MinusIcon
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
|
||||
@@ -1,132 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import {
|
||||
MessageScroller as MessageScrollerPrimitive,
|
||||
useMessageScroller,
|
||||
useMessageScrollerScrollable,
|
||||
useMessageScrollerVisibility,
|
||||
} from "@shadcn/react/message-scroller"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { t } from "@/i18n"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { ArrowDownIcon } from "lucide-react"
|
||||
|
||||
function MessageScrollerProvider(
|
||||
props: React.ComponentProps<typeof MessageScrollerPrimitive.Provider>
|
||||
) {
|
||||
return <MessageScrollerPrimitive.Provider {...props} />
|
||||
}
|
||||
|
||||
function MessageScroller({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof MessageScrollerPrimitive.Root>) {
|
||||
return (
|
||||
<MessageScrollerPrimitive.Root
|
||||
data-slot="message-scroller"
|
||||
className={cn(
|
||||
"group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function MessageScrollerViewport({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof MessageScrollerPrimitive.Viewport>) {
|
||||
return (
|
||||
<MessageScrollerPrimitive.Viewport
|
||||
data-slot="message-scroller-viewport"
|
||||
className={cn(
|
||||
"size-full min-h-0 min-w-0 scroll-fade-b scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content data-autoscrolling:scrollbar-thumb-transparent data-autoscrolling:scrollbar-track-transparent",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function MessageScrollerContent({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof MessageScrollerPrimitive.Content>) {
|
||||
return (
|
||||
<MessageScrollerPrimitive.Content
|
||||
data-slot="message-scroller-content"
|
||||
className={cn("flex h-max min-h-full flex-col gap-6", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function MessageScrollerItem({
|
||||
className,
|
||||
scrollAnchor = false,
|
||||
...props
|
||||
}: React.ComponentProps<typeof MessageScrollerPrimitive.Item>) {
|
||||
return (
|
||||
<MessageScrollerPrimitive.Item
|
||||
data-slot="message-scroller-item"
|
||||
scrollAnchor={scrollAnchor}
|
||||
className={cn(
|
||||
"min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function MessageScrollerButton({
|
||||
direction = "end",
|
||||
className,
|
||||
children,
|
||||
render,
|
||||
variant = "secondary",
|
||||
size = "icon-sm",
|
||||
...props
|
||||
}: React.ComponentProps<typeof MessageScrollerPrimitive.Button> &
|
||||
Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
|
||||
return (
|
||||
<MessageScrollerPrimitive.Button
|
||||
data-slot="message-scroller-button"
|
||||
data-direction={direction}
|
||||
data-variant={variant}
|
||||
data-size={size}
|
||||
direction={direction}
|
||||
className={cn(
|
||||
"absolute inset-s-1/2 -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-muted hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] data-[direction=end]:bottom-4 data-[direction=end]:data-[active=false]:translate-y-full data-[direction=start]:top-4 data-[direction=start]:data-[active=false]:-translate-y-full rtl:translate-x-1/2 data-[direction=start]:[&_svg]:rotate-180",
|
||||
className
|
||||
)}
|
||||
render={render ?? <Button variant={variant} size={size} />}
|
||||
{...props}
|
||||
>
|
||||
{children ?? (
|
||||
<>
|
||||
<ArrowDownIcon
|
||||
/>
|
||||
<span className="sr-only">
|
||||
{direction === "end" ? t("Scroll to end") : t("Scroll to start")}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</MessageScrollerPrimitive.Button>
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
MessageScrollerProvider,
|
||||
MessageScroller,
|
||||
MessageScrollerViewport,
|
||||
MessageScrollerContent,
|
||||
MessageScrollerItem,
|
||||
MessageScrollerButton,
|
||||
useMessageScroller,
|
||||
useMessageScrollerScrollable,
|
||||
useMessageScrollerVisibility,
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import * as React from "react";
|
||||
|
||||
const LG_BREAKPOINT = 1024;
|
||||
|
||||
export function useIsLg() {
|
||||
const [isLg, setIsLg] = React.useState<boolean | undefined>(undefined);
|
||||
|
||||
React.useEffect(() => {
|
||||
const mql = window.matchMedia(`(min-width: ${LG_BREAKPOINT}px)`);
|
||||
const onChange = () => {
|
||||
setIsLg(window.innerWidth >= LG_BREAKPOINT);
|
||||
};
|
||||
mql.addEventListener("change", onChange);
|
||||
setIsLg(window.innerWidth >= LG_BREAKPOINT);
|
||||
return () => mql.removeEventListener("change", onChange);
|
||||
}, []);
|
||||
|
||||
return !!isLg;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
# UI localization
|
||||
|
||||
English source text is the translation key. `t(key, vars)` is shared by React
|
||||
components, module constants, toasts and non-React helpers; missing keys fall back
|
||||
to English. Keep keys, `{name}` placeholders, HTML formatting tags, Go template
|
||||
actions and literal command/API examples intact when adding translations.
|
||||
|
||||
The registered locales are English (`en`), Turkish (`tr`) and Simplified Chinese
|
||||
(`zh-CN`). The Preferences language control renders `LOCALES` directly. A saved
|
||||
`artex.locale` browser preference takes priority over browser language detection;
|
||||
otherwise an exact language tag, then its base language, is matched. Chinese
|
||||
browser variants use the available Simplified Chinese dictionary. Static export
|
||||
and unsupported languages retain the English default. Switching language saves
|
||||
the preference and reloads the page, following the existing module-level design.
|
||||
|
||||
To add a locale, add `locales/<code>.json` and register it in `Locale`, `LOCALES`,
|
||||
`DICTIONARIES` and `INTL_LOCALES` in `index.ts`. Date/number formatting uses
|
||||
`intlLocale`, and the HTML `lang` attribute follows the selected locale.
|
||||
|
||||
Run `npm run test:i18n` and `npm run build:static` from `web/`. The dictionary
|
||||
checker covers every locale, checks literal call sites, requires matching keys
|
||||
including dynamic entries, and validates placeholders. Runtime tests exercise
|
||||
language detection, persistence, English fallback and prototype-safe lookups.
|
||||
|
||||
The initial Simplified Chinese dictionary reuses Chinese wording from this
|
||||
repository's parent of commit `e233c02` (the English translation migration), with
|
||||
additional translations for current functionality and normalized UI terminology.
|
||||
This only localizes interface text; backend data, user content, model responses,
|
||||
protocol identifiers and tool output are not rewritten.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user