Merge licensing: shipped notices, Apache-2.0 core files and LGPL terms
Every installer and the server archive carry LICENSE and the third-party notices, and Settings > General links to both. The files copied from hive-mind-core keep Apache-2.0 with SPDX headers. The LGPL components name their versions and where their source is. ADR-0010 settles the marketplace catalog question. Logs UF-069 and marks UF-059 Fixed.
This commit is contained in:
202
packages/core/LICENSE-APACHE
Normal file
202
packages/core/LICENSE-APACHE
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
47
packages/core/LICENSE.md
Normal file
47
packages/core/LICENSE.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# License of `@waggle/core`
|
||||
|
||||
This package is licensed under the MIT License (the `LICENSE` file at the repository root),
|
||||
except the files listed below. They were copied from `@waggle/hive-mind-core`, a package of
|
||||
the commercial Waggle repository licensed under the Apache License, Version 2.0, and keep that
|
||||
license. The full license text is in [`LICENSE-APACHE`](LICENSE-APACHE).
|
||||
|
||||
Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
|
||||
Each file starts with an `SPDX-License-Identifier: Apache-2.0` header, this copyright line and
|
||||
the file it was copied from. The source files are bundled into the sidecar (`service.js`), so
|
||||
`THIRD_PARTY_NOTICES.md` lists them as well; the tests do not ship.
|
||||
`tests/license-headers.test.ts` checks that this list and the headers agree.
|
||||
|
||||
| File | Copied from (`packages/hive-mind-core/`) | Changed |
|
||||
|---|---|---|
|
||||
| `src/awareness.ts` | `src/mind/awareness.ts` | yes |
|
||||
| `src/embeddings/api-embedder.ts` | `src/mind/api-embedder.ts` | no |
|
||||
| `src/embeddings/embedding-provider.ts` | `src/mind/embedding-provider.ts` | yes |
|
||||
| `src/embeddings/embeddings.ts` | `src/mind/embeddings.ts` | parts (the `Embedder` interface) |
|
||||
| `src/embeddings/inprocess-embedder.ts` | `src/mind/inprocess-embedder.ts` | yes |
|
||||
| `src/embeddings/litellm-embedder.ts` | `src/mind/litellm-embedder.ts` | no |
|
||||
| `src/embeddings/ollama-embedder.ts` | `src/mind/ollama-embedder.ts` | no |
|
||||
| `src/embeddings/transformers-model-load.ts` | `src/mind/transformers-model-load.ts` | no |
|
||||
| `src/execution-traces.ts` | `src/mind/execution-traces.ts` | yes |
|
||||
| `src/identity.ts` | `src/mind/identity.ts` | yes |
|
||||
| `src/injection-scanner.ts` | `src/injection-scanner.ts` | no |
|
||||
| `src/logger.ts` | `src/logger.ts` | yes |
|
||||
| `src/memory-ingress-guard.ts` | `src/memory-ingress-guard.ts` | no |
|
||||
| `src/recall/inprocess-reranker.ts` | `src/mind/inprocess-reranker.ts` | yes |
|
||||
| `src/recall/parse-date-window.ts` | `src/mind/parse-date-window.ts` | yes |
|
||||
| `src/recall/recall-context.ts` | `src/mind/recall-context.ts` | no |
|
||||
| `src/recall/resolve-relative-date.ts` | `src/mind/resolve-relative-date.ts` | yes |
|
||||
| `src/waggle-db.ts` | `src/mind/db.ts` | parts (the connection setup and the meta accessors) |
|
||||
| `src/workspace-manager.ts` | `src/workspace-manager.ts` | yes |
|
||||
| `tests/embeddings/embedding-provider.test.ts` | `tests/mind/embedding-provider.test.ts` | yes |
|
||||
| `tests/embeddings/inprocess-embedder.test.ts` | `tests/mind/inprocess-embedder.test.ts` | yes |
|
||||
| `tests/embeddings/transformers-model-load.test.ts` | `tests/mind/transformers-model-load.test.ts` | yes |
|
||||
| `tests/logger.test.ts` | `tests/logger.test.ts` | yes |
|
||||
| `tests/memory-ingress-guard.test.ts` | `tests/memory-ingress-guard.test.ts` | yes |
|
||||
| `tests/recall/inprocess-reranker.test.ts` | `tests/mind/inprocess-reranker.test.ts` | yes |
|
||||
| `tests/recall/parse-date-window.test.ts` | `tests/mind/parse-date-window.test.ts` | yes |
|
||||
| `tests/recall/resolve-relative-date.test.ts` | `tests/mind/resolve-relative-date.test.ts` | yes |
|
||||
| `tests/workspace-manager.test.ts` | `tests/workspace-manager.test.ts` | yes |
|
||||
|
||||
New files in this package and changes to the MIT files are MIT-licensed. A file added here
|
||||
from `@waggle/hive-mind-core` needs the same header and a row in this table.
|
||||
@@ -27,5 +27,5 @@
|
||||
"devDependencies": {
|
||||
"@types/better-sqlite3": "^7.6.13"
|
||||
},
|
||||
"license": "MIT"
|
||||
"license": "MIT AND Apache-2.0"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/awareness.ts and changed for @waggle/core.
|
||||
/**
|
||||
* AwarenessLayer — the agent's short-lived working items (tasks, recent
|
||||
* actions, pending items, context flags), per data scope, stored in waggle.db.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/api-embedder.ts without changes.
|
||||
/**
|
||||
* API-backed embedder — calls Voyage AI or OpenAI embedding endpoints.
|
||||
* For users who configure API keys in the Vault UI.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/embedding-provider.ts and changed for @waggle/core.
|
||||
/**
|
||||
* EmbeddingProvider — orchestrates the InProcess → Ollama → API → Mock fallback chain.
|
||||
* Single entry point for all embedding operations in Waggle.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Parts copied from @waggle/hive-mind-core src/mind/embeddings.ts and changed for @waggle/core.
|
||||
export interface Embedder {
|
||||
embed(text: string): Promise<Float32Array>;
|
||||
embedBatch(texts: string[]): Promise<Float32Array[]>;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/inprocess-embedder.ts and changed for @waggle/core.
|
||||
/**
|
||||
* In-process embedder using @huggingface/transformers (ONNX Runtime).
|
||||
* Default provider for ALL desktop users — zero config, works offline.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/litellm-embedder.ts without changes.
|
||||
/**
|
||||
* LiteLLM-backed embedder that calls the /embeddings endpoint.
|
||||
* Falls back to a deterministic mock (text→Float32Array hash) on API error
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/ollama-embedder.ts without changes.
|
||||
/**
|
||||
* Ollama-backed embedder — calls local Ollama server for embeddings.
|
||||
* Power user option for users who have Ollama installed.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/transformers-model-load.ts without changes.
|
||||
import { createHash, randomUUID } from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/execution-traces.ts and changed for @waggle/core.
|
||||
import type { WaggleDB } from './waggle-db.js';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/identity.ts and changed for @waggle/core.
|
||||
/**
|
||||
* IdentityLayer — the user profile card, one per data scope, stored in
|
||||
* waggle.db. The card is what the user writes and edits; facts the agent
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/injection-scanner.ts without changes.
|
||||
/**
|
||||
* Prompt-injection scanner — pattern-based detection for role-override,
|
||||
* prompt-extraction, and instruction-injection attempts.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/logger.ts and changed for @waggle/core.
|
||||
/** Minimal structured logger for @waggle/core */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/memory-ingress-guard.ts without changes.
|
||||
import { scanForInjection, type ScanResult } from './injection-scanner.js';
|
||||
|
||||
export interface ExternalMemoryIngressInput {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/inprocess-reranker.ts and changed for @waggle/core.
|
||||
/**
|
||||
* In-process cross-encoder reranker using @huggingface/transformers (ONNX).
|
||||
*
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/parse-date-window.ts and changed for @waggle/core.
|
||||
/**
|
||||
* parse-date-window.ts — deterministic query-side temporal-constraint parser
|
||||
* (W4.1b, production port of the benchmark-proven Wave-3.1 date-window lane;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/recall-context.ts without changes.
|
||||
/**
|
||||
* recall-context.ts — shared renderer for surfacing temporal information in
|
||||
* recalled-memory blocks. Single source of truth imported by both the Waggle
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/mind/resolve-relative-date.ts and changed for @waggle/core.
|
||||
/**
|
||||
* resolve-relative-date — write-time relative-date resolution for the memory substrate.
|
||||
*
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Parts copied from @waggle/hive-mind-core src/mind/db.ts and changed for @waggle/core.
|
||||
/**
|
||||
* waggle.db — Waggle's own data, kept apart from memory (ADR-0007).
|
||||
*
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core src/workspace-manager.ts and changed for @waggle/core.
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import type { WorkspaceType } from '@waggle/shared';
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core tests/mind/embedding-provider.test.ts and changed for @waggle/core.
|
||||
/**
|
||||
* createEmbeddingProvider tests: the generic mock fallback, dimension respect,
|
||||
* deterministic-vector behavior, batch shape and the reprobe contract.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core tests/mind/inprocess-embedder.test.ts and changed for @waggle/core.
|
||||
/**
|
||||
* In-process embedder tests: `normalizeDimensions(input, target)` and its
|
||||
* "no-copy fast path when dims match" contract.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core tests/mind/transformers-model-load.test.ts and changed for @waggle/core.
|
||||
import { spawn, type ChildProcess } from 'node:child_process';
|
||||
import { once } from 'node:events';
|
||||
import fs from 'node:fs';
|
||||
|
||||
51
packages/core/tests/license-headers.test.ts
Normal file
51
packages/core/tests/license-headers.test.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* The Apache-2.0 files of @waggle/core (copied from @waggle/hive-mind-core)
|
||||
* carry an SPDX header, and LICENSE.md lists exactly those files.
|
||||
*/
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const PACKAGE_DIR = path.resolve(import.meta.dirname, '..');
|
||||
const APACHE_HEADER = /^\/\/ SPDX-License-Identifier: Apache-2\.0\n\/\/ Copyright 2026 Marko Marković · Egzakta Group · waggle-os\.ai\n\/\/ (?:Parts copied|Copied) from @waggle\/hive-mind-core (\S+) (?:without changes|and changed for @waggle\/core)\.\n/;
|
||||
|
||||
function sourceFiles(dir: string): string[] {
|
||||
return fs.readdirSync(path.join(PACKAGE_DIR, dir), { withFileTypes: true }).flatMap((entry) => {
|
||||
const relative = `${dir}/${entry.name}`;
|
||||
if (entry.isDirectory()) return sourceFiles(relative);
|
||||
return /\.tsx?$/.test(entry.name) ? [relative] : [];
|
||||
});
|
||||
}
|
||||
|
||||
describe('@waggle/core license headers', () => {
|
||||
const headed = new Map<string, string>();
|
||||
for (const file of [...sourceFiles('src'), ...sourceFiles('tests')]) {
|
||||
const text = fs.readFileSync(path.join(PACKAGE_DIR, file), 'utf8');
|
||||
if (text.startsWith('// SPDX-License-Identifier')) {
|
||||
const match = APACHE_HEADER.exec(text);
|
||||
expect(match, `${file} has a malformed SPDX header`).not.toBeNull();
|
||||
headed.set(file, match![1]);
|
||||
}
|
||||
}
|
||||
const listed = new Map(
|
||||
[...fs.readFileSync(path.join(PACKAGE_DIR, 'LICENSE.md'), 'utf8')
|
||||
.matchAll(/^\| `([^`]+)` \| `([^`]+)` \|/gm)]
|
||||
.map((match) => [match[1], match[2]]),
|
||||
);
|
||||
|
||||
it('lists every Apache-2.0 file in LICENSE.md with the file it came from', () => {
|
||||
expect(headed.size).toBeGreaterThan(0);
|
||||
expect(Object.fromEntries(listed)).toEqual(Object.fromEntries(headed));
|
||||
});
|
||||
|
||||
it('ships the full Apache-2.0 text next to the note', () => {
|
||||
const text = fs.readFileSync(path.join(PACKAGE_DIR, 'LICENSE-APACHE'), 'utf8');
|
||||
expect(text).toContain('TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION');
|
||||
expect(text).toContain('END OF TERMS AND CONDITIONS');
|
||||
});
|
||||
|
||||
it('declares both licenses in package.json', () => {
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(PACKAGE_DIR, 'package.json'), 'utf8'));
|
||||
expect(manifest.license).toBe('MIT AND Apache-2.0');
|
||||
});
|
||||
});
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core tests/logger.test.ts and changed for @waggle/core.
|
||||
/**
|
||||
* Logger stderr-routing tests.
|
||||
*
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core tests/memory-ingress-guard.test.ts and changed for @waggle/core.
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import {
|
||||
evaluateExternalMemoryIngress,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core tests/mind/inprocess-reranker.test.ts and changed for @waggle/core.
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core tests/mind/parse-date-window.test.ts and changed for @waggle/core.
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseDateWindow } from '../../src/recall/parse-date-window.js';
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core tests/mind/resolve-relative-date.test.ts and changed for @waggle/core.
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { resolveRelativeDate } from '../../src/recall/resolve-relative-date.js';
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2026 Marko Marković · Egzakta Group · waggle-os.ai
|
||||
// Copied from @waggle/hive-mind-core tests/workspace-manager.test.ts and changed for @waggle/core.
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
@@ -169,6 +169,8 @@ describe.skipIf(!target)('install, update and uninstall from a packed archive',
|
||||
fs.writeFileSync(path.join(resources, process.platform === 'win32' ? 'node.exe' : 'node'), 'not a real runtime');
|
||||
fs.writeFileSync(path.join(resources, 'service.js'), 'console.log("service");\n');
|
||||
fs.writeFileSync(path.join(resources, 'service.js.map'), '{}');
|
||||
fs.writeFileSync(path.join(resources, 'LICENSE'), 'MIT License\n');
|
||||
fs.writeFileSync(path.join(resources, 'THIRD_PARTY_NOTICES.md'), '# Third-party notices\n');
|
||||
fs.writeFileSync(path.join(web, 'index.html'), '<!doctype html>');
|
||||
const out = path.join(work, 'out');
|
||||
const result = spawnSync(
|
||||
@@ -204,6 +206,9 @@ describe.skipIf(!target)('install, update and uninstall from a packed archive',
|
||||
expect(fs.readFileSync(path.join(layout.appDir, 'service.js'), 'utf8')).toContain('service');
|
||||
expect(fs.existsSync(path.join(layout.appDir, 'web', 'index.html'))).toBe(true);
|
||||
expect(fs.existsSync(path.join(layout.appDir, 'service.js.map'))).toBe(false);
|
||||
// UF-059: the license and the notices are installed next to service.js.
|
||||
expect(fs.readFileSync(path.join(layout.appDir, 'THIRD_PARTY_NOTICES.md'), 'utf8')).toContain('Third-party notices');
|
||||
expect(fs.existsSync(path.join(layout.appDir, 'LICENSE'))).toBe(true);
|
||||
expect(fs.readFileSync(layout.launcherFile, 'utf8')).toBe('// bundled tool\n');
|
||||
const record = readRecord(layout);
|
||||
expect(record).toMatchObject({ version: VERSION, target, source: archive });
|
||||
|
||||
@@ -156,6 +156,7 @@ import { identityRoutes } from './routes/identity.js';
|
||||
import { agentRunRoutes } from './routes/agent-run.js';
|
||||
import { agentRunsRoutes } from './routes/agent-runs.js';
|
||||
import { localInferenceRoutes } from './routes/local-inference.js';
|
||||
import { legalRoutes } from './routes/legal.js';
|
||||
import { OfflineManager } from './offline-manager.js';
|
||||
import { listOllamaChatModelIds } from './model-availability.js';
|
||||
import { log, createLogger } from './logger.js';
|
||||
@@ -2045,6 +2046,7 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
|
||||
await server.register(agentRunRoutes);
|
||||
await server.register(agentRunsRoutes);
|
||||
await server.register(localInferenceRoutes);
|
||||
await server.register(legalRoutes);
|
||||
|
||||
// ── Static file serving for web mode ──────────────────────────
|
||||
// When WAGGLE_FRONTEND_DIR is set, serve the React frontend as static files.
|
||||
|
||||
47
packages/server/src/local/routes/legal.ts
Normal file
47
packages/server/src/local/routes/legal.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* The license and the third-party notices, read-only, for Settings (UF-059).
|
||||
*
|
||||
* GET /api/legal/license LICENSE, text/plain
|
||||
* GET /api/legal/third-party-notices THIRD_PARTY_NOTICES.md, text/markdown
|
||||
*
|
||||
* The desktop app and the server archive carry both files next to service.js
|
||||
* (scripts/build-sidecar.mjs). Run from source, they come from the repository root.
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
|
||||
const LEGAL_DOCUMENTS = [
|
||||
{ route: '/api/legal/license', file: 'LICENSE', contentType: 'text/plain; charset=utf-8' },
|
||||
{ route: '/api/legal/third-party-notices', file: 'THIRD_PARTY_NOTICES.md', contentType: 'text/markdown; charset=utf-8' },
|
||||
] as const;
|
||||
|
||||
export interface LegalRoutesOptions {
|
||||
/** Directories searched in order for the files. */
|
||||
searchDirs?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* The directory of this module (service.js in a packaged build), then the
|
||||
* repository root when this module runs from packages/server/{src,dist}/local/routes.
|
||||
*/
|
||||
export function defaultLegalSearchDirs(moduleDir = path.dirname(fileURLToPath(import.meta.url))): string[] {
|
||||
const repositoryRoot = path.resolve(moduleDir, '..', '..', '..', '..', '..');
|
||||
const fromSource = fs.existsSync(path.join(repositoryRoot, 'packages', 'server', 'package.json'));
|
||||
return fromSource ? [moduleDir, repositoryRoot] : [moduleDir];
|
||||
}
|
||||
|
||||
export async function legalRoutes(fastify: FastifyInstance, options: LegalRoutesOptions = {}) {
|
||||
const searchDirs = options.searchDirs ?? defaultLegalSearchDirs();
|
||||
for (const document of LEGAL_DOCUMENTS) {
|
||||
fastify.get(document.route, async (_request, reply) => {
|
||||
const file = searchDirs.map((dir) => path.join(dir, document.file)).find((candidate) => fs.existsSync(candidate));
|
||||
if (!file) {
|
||||
return reply.code(404).send({ error: `${document.file} is not part of this installation` });
|
||||
}
|
||||
return reply.type(document.contentType).send(await fs.promises.readFile(file, 'utf8'));
|
||||
});
|
||||
}
|
||||
}
|
||||
116
packages/server/tests/local/legal-routes.test.ts
Normal file
116
packages/server/tests/local/legal-routes.test.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* GET /api/legal/license and GET /api/legal/third-party-notices (UF-059).
|
||||
*
|
||||
* Packaged builds read the files next to service.js; a source checkout reads
|
||||
* them from the repository root.
|
||||
*/
|
||||
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import Fastify, { type FastifyInstance } from 'fastify';
|
||||
import { buildLocalServer } from '../../src/local/index.js';
|
||||
import { defaultLegalSearchDirs, legalRoutes } from '../../src/local/routes/legal.js';
|
||||
import { injectWithAuth } from '../test-utils.js';
|
||||
|
||||
const REPO_ROOT = path.resolve(import.meta.dirname, '..', '..', '..', '..');
|
||||
const ROUTES_DIR = path.resolve(import.meta.dirname, '..', '..', 'src', 'local', 'routes');
|
||||
|
||||
const temps: string[] = [];
|
||||
function tempDir(): string {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-legal-'));
|
||||
temps.push(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
async function serverWith(searchDirs: string[]): Promise<FastifyInstance> {
|
||||
const server = Fastify({ logger: false });
|
||||
await server.register(legalRoutes, { searchDirs });
|
||||
return server;
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
for (const dir of temps.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
describe('legal routes', () => {
|
||||
it('serves the copies next to service.js in a packaged build', async () => {
|
||||
const resources = tempDir();
|
||||
fs.writeFileSync(path.join(resources, 'LICENSE'), 'MIT License (packaged)\n');
|
||||
fs.writeFileSync(path.join(resources, 'THIRD_PARTY_NOTICES.md'), '# Third-party notices (packaged)\n');
|
||||
const server = await serverWith(defaultLegalSearchDirs(resources));
|
||||
try {
|
||||
const notices = await server.inject({ method: 'GET', url: '/api/legal/third-party-notices' });
|
||||
expect(notices.statusCode).toBe(200);
|
||||
expect(notices.headers['content-type']).toBe('text/markdown; charset=utf-8');
|
||||
expect(notices.payload).toBe('# Third-party notices (packaged)\n');
|
||||
|
||||
const license = await server.inject({ method: 'GET', url: '/api/legal/license' });
|
||||
expect(license.statusCode).toBe(200);
|
||||
expect(license.headers['content-type']).toBe('text/plain; charset=utf-8');
|
||||
expect(license.payload).toBe('MIT License (packaged)\n');
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
});
|
||||
|
||||
it('falls back to the repository root when run from source', async () => {
|
||||
expect(defaultLegalSearchDirs(ROUTES_DIR)).toEqual([ROUTES_DIR, REPO_ROOT]);
|
||||
const server = await serverWith(defaultLegalSearchDirs(ROUTES_DIR));
|
||||
try {
|
||||
const notices = await server.inject({ method: 'GET', url: '/api/legal/third-party-notices' });
|
||||
expect(notices.statusCode).toBe(200);
|
||||
expect(notices.payload).toBe(fs.readFileSync(path.join(REPO_ROOT, 'THIRD_PARTY_NOTICES.md'), 'utf8'));
|
||||
const license = await server.inject({ method: 'GET', url: '/api/legal/license' });
|
||||
expect(license.payload).toBe(fs.readFileSync(path.join(REPO_ROOT, 'LICENSE'), 'utf8'));
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not look outside the packaged folder when it is not in a source checkout', () => {
|
||||
const resources = tempDir();
|
||||
expect(defaultLegalSearchDirs(resources)).toEqual([resources]);
|
||||
});
|
||||
|
||||
it('answers 404 when a file is missing', async () => {
|
||||
const server = await serverWith([tempDir()]);
|
||||
try {
|
||||
const res = await server.inject({ method: 'GET', url: '/api/legal/third-party-notices' });
|
||||
expect(res.statusCode).toBe(404);
|
||||
expect(JSON.parse(res.payload).error).toContain('THIRD_PARTY_NOTICES.md');
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('legal routes in the sidecar', () => {
|
||||
let server: FastifyInstance;
|
||||
let dataDir: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
// Exercise the real auth path: no loopback trust (vitest.setup.ts turns it on).
|
||||
vi.stubEnv('WAGGLE_TRUST_LOCALHOST', '0');
|
||||
dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-legal-server-'));
|
||||
server = await buildLocalServer({ dataDir });
|
||||
}, 60_000);
|
||||
|
||||
afterAll(async () => {
|
||||
await server.close();
|
||||
fs.rmSync(dataDir, { recursive: true, force: true });
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it('serves the notices to an authenticated client', async () => {
|
||||
const res = await injectWithAuth(server, { method: 'GET', url: '/api/legal/third-party-notices' });
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.payload).toContain('# Third-party notices');
|
||||
});
|
||||
|
||||
it('requires the session token like every other API route', async () => {
|
||||
const res = await server.inject({ method: 'GET', url: '/api/legal/third-party-notices' });
|
||||
expect(res.statusCode).toBe(401);
|
||||
});
|
||||
});
|
||||
@@ -218,6 +218,16 @@ describe('Tauri Production Configuration', () => {
|
||||
expect(conf.bundle.resources).toContain('resources/starter-skills/*');
|
||||
});
|
||||
|
||||
it('bundles LICENSE and THIRD_PARTY_NOTICES.md next to service.js, untracked (UF-059)', () => {
|
||||
// `resources/*` covers the top-level files build-sidecar.mjs copies there.
|
||||
const conf = JSON.parse(fs.readFileSync(path.join(TAURI_DIR, 'tauri.conf.json'), 'utf-8'));
|
||||
expect(conf.bundle.resources).toContain('resources/*');
|
||||
for (const name of ['LICENSE', 'THIRD_PARTY_NOTICES.md']) {
|
||||
const ignored = spawnSync('git', ['check-ignore', '-q', `app/src-tauri/resources/${name}`], { cwd: ROOT });
|
||||
expect(ignored.status, `${name} copy is not ignored`).toBe(0);
|
||||
}
|
||||
});
|
||||
|
||||
it('tauri.conf.json has correct window settings', () => {
|
||||
const conf = JSON.parse(fs.readFileSync(path.join(TAURI_DIR, 'tauri.conf.json'), 'utf-8'));
|
||||
const win = conf.app.windows[0];
|
||||
@@ -479,6 +489,8 @@ describe('Tauri Production Configuration', () => {
|
||||
path.join(fixtureRoot, 'scripts', 'build-sidecar.mjs'),
|
||||
);
|
||||
const trackedFiles = new Map<string, string>([
|
||||
['LICENSE', 'MIT License\n'],
|
||||
['THIRD_PARTY_NOTICES.md', '# Third-party notices\n'],
|
||||
['package-lock.json', '{"lockfileVersion":3}\n'],
|
||||
['package.json', '{"name":"sidecar-tsconfig-fixture","private":true}\n'],
|
||||
['packages/marketplace/marketplace.db', 'fixture database'],
|
||||
@@ -575,6 +587,10 @@ describe('Tauri Production Configuration', () => {
|
||||
const resourcesRoot = path.join(fixtureRoot, 'app', 'src-tauri', 'resources');
|
||||
expect(fs.existsSync(path.join(resourcesRoot, 'capability-packs', 'research-workflow.json'))).toBe(true);
|
||||
expect(fs.existsSync(path.join(resourcesRoot, 'starter-skills', 'brainstorm.md'))).toBe(true);
|
||||
// UF-059: the license and the notices ship next to service.js.
|
||||
for (const name of ['LICENSE', 'THIRD_PARTY_NOTICES.md']) {
|
||||
expect(fs.readFileSync(path.join(resourcesRoot, name), 'utf8')).toBe(trackedFiles.get(name));
|
||||
}
|
||||
|
||||
fs.writeFileSync(marketplacePath, 'dirty worktree database');
|
||||
const dirtyMarketplaceResult = runResult(
|
||||
|
||||
Reference in New Issue
Block a user