@plasius/ai 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/CODE_OF_CONDUCT.md +79 -0
- package/CONTRIBUTORS.md +27 -0
- package/LICENSE +21 -0
- package/README.md +132 -0
- package/SECURITY.md +17 -0
- package/dist/components/pixelverse/balance.d.ts +4 -0
- package/dist/components/pixelverse/balance.d.ts.map +1 -0
- package/dist/components/pixelverse/balance.js +40 -0
- package/dist/components/pixelverse/index.d.ts +3 -0
- package/dist/components/pixelverse/index.d.ts.map +1 -0
- package/dist/components/pixelverse/index.js +2 -0
- package/dist/components/pixelverse/pixelverseeditor.d.ts +16 -0
- package/dist/components/pixelverse/pixelverseeditor.d.ts.map +1 -0
- package/dist/components/pixelverse/pixelverseeditor.js +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/chatWithAI.d.ts +2 -0
- package/dist/lib/chatWithAI.d.ts.map +1 -0
- package/dist/lib/chatWithAI.js +1 -0
- package/dist/lib/generateImage.d.ts +2 -0
- package/dist/lib/generateImage.d.ts.map +1 -0
- package/dist/lib/generateImage.js +1 -0
- package/dist/lib/synthesizeSpeech.d.ts +2 -0
- package/dist/lib/synthesizeSpeech.d.ts.map +1 -0
- package/dist/lib/synthesizeSpeech.js +1 -0
- package/dist/lib/transcribeSpeech.d.ts +2 -0
- package/dist/lib/transcribeSpeech.d.ts.map +1 -0
- package/dist/lib/transcribeSpeech.js +1 -0
- package/dist/platform/index.d.ts +76 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +125 -0
- package/dist/platform/openai.d.ts +8 -0
- package/dist/platform/openai.d.ts.map +1 -0
- package/dist/platform/openai.js +61 -0
- package/dist/platform/pixelverse.d.ts +6 -0
- package/dist/platform/pixelverse.d.ts.map +1 -0
- package/dist/platform/pixelverse.js +196 -0
- package/dist-cjs/components/pixelverse/balance.d.ts +4 -0
- package/dist-cjs/components/pixelverse/balance.d.ts.map +1 -0
- package/dist-cjs/components/pixelverse/balance.js +46 -0
- package/dist-cjs/components/pixelverse/index.d.ts +3 -0
- package/dist-cjs/components/pixelverse/index.d.ts.map +1 -0
- package/dist-cjs/components/pixelverse/index.js +18 -0
- package/dist-cjs/components/pixelverse/pixelverseeditor.d.ts +16 -0
- package/dist-cjs/components/pixelverse/pixelverseeditor.d.ts.map +1 -0
- package/dist-cjs/components/pixelverse/pixelverseeditor.js +27 -0
- package/dist-cjs/index.d.ts +2 -0
- package/dist-cjs/index.d.ts.map +1 -0
- package/dist-cjs/index.js +17 -0
- package/dist-cjs/lib/chatWithAI.d.ts +1 -0
- package/dist-cjs/lib/chatWithAI.d.ts.map +1 -0
- package/dist-cjs/lib/chatWithAI.js +1 -0
- package/dist-cjs/lib/generateImage.d.ts +1 -0
- package/dist-cjs/lib/generateImage.d.ts.map +1 -0
- package/dist-cjs/lib/generateImage.js +1 -0
- package/dist-cjs/lib/synthesizeSpeech.d.ts +1 -0
- package/dist-cjs/lib/synthesizeSpeech.d.ts.map +1 -0
- package/dist-cjs/lib/synthesizeSpeech.js +1 -0
- package/dist-cjs/lib/transcribeSpeech.d.ts +1 -0
- package/dist-cjs/lib/transcribeSpeech.d.ts.map +1 -0
- package/dist-cjs/lib/transcribeSpeech.js +1 -0
- package/dist-cjs/platform/index.d.ts +76 -0
- package/dist-cjs/platform/index.d.ts.map +1 -0
- package/dist-cjs/platform/index.js +128 -0
- package/dist-cjs/platform/openai.d.ts +8 -0
- package/dist-cjs/platform/openai.d.ts.map +1 -0
- package/dist-cjs/platform/openai.js +67 -0
- package/dist-cjs/platform/pixelverse.d.ts +6 -0
- package/dist-cjs/platform/pixelverse.d.ts.map +1 -0
- package/dist-cjs/platform/pixelverse.js +199 -0
- package/docs/adrs/adr-0001-ai-package-scope.md +21 -0
- package/docs/adrs/adr-0002-public-repo-governance.md +24 -0
- package/docs/adrs/adr-0003-contracts-first-documentation.md +25 -0
- package/docs/adrs/adr-template.md +35 -0
- package/docs/api-reference.md +64 -0
- package/docs/architecture.md +21 -0
- package/docs/providers.md +26 -0
- package/legal/CLA-REGISTRY.csv +1 -0
- package/legal/CLA.md +22 -0
- package/legal/CORPORATE_CLA.md +57 -0
- package/legal/INDIVIDUAL_CLA.md +91 -0
- package/package.json +117 -0
- package/src/components/pixelverse/balance.module.css +6 -0
- package/src/components/pixelverse/balance.tsx +65 -0
- package/src/components/pixelverse/index.ts +2 -0
- package/src/components/pixelverse/pixelverseeditor.mocule.css +0 -0
- package/src/components/pixelverse/pixelverseeditor.tsx +74 -0
- package/src/global.d.ts +9 -0
- package/src/index.ts +1 -0
- package/src/lib/chatWithAI.ts +0 -0
- package/src/lib/generateImage.ts +0 -0
- package/src/lib/synthesizeSpeech.ts +0 -0
- package/src/lib/transcribeSpeech.ts +0 -0
- package/src/platform/index.ts +237 -0
- package/src/platform/openai.ts +123 -0
- package/src/platform/pixelverse.ts +309 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
`@plasius/ai` is structured as a contracts-first package:
|
|
4
|
+
|
|
5
|
+
- **Capability model**: `AICapability` describes the logical feature set.
|
|
6
|
+
- **Platform contract**: `AIPlatform` defines the async operations required by a runtime adapter.
|
|
7
|
+
- **Completion contracts**: typed completion outputs normalize chat/text/image/speech/video/balance results.
|
|
8
|
+
- **Schema layer**: schema definitions ensure consistent metadata and persistence shape across runtimes.
|
|
9
|
+
|
|
10
|
+
## Design Intention
|
|
11
|
+
|
|
12
|
+
This package is not tied to a single provider runtime. Host applications should:
|
|
13
|
+
|
|
14
|
+
1. Implement or wrap an `AIPlatform` adapter.
|
|
15
|
+
2. Keep provider credentials and network execution outside this package boundary.
|
|
16
|
+
3. Emit normalized completion objects based on the exported contract types.
|
|
17
|
+
|
|
18
|
+
## Current Boundaries
|
|
19
|
+
|
|
20
|
+
- Public API: contracts and schemas from `src/platform/index.ts`.
|
|
21
|
+
- Internal/provisional: files under `src/lib` and in-progress provider runtime glue.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Provider Guidance
|
|
2
|
+
|
|
3
|
+
This package defines provider contracts but does not require consumers to use a
|
|
4
|
+
specific provider implementation.
|
|
5
|
+
|
|
6
|
+
## Recommended Integration Pattern
|
|
7
|
+
|
|
8
|
+
1. Build provider adapters in your host app or a dedicated integration package.
|
|
9
|
+
2. Implement `AIPlatform` for each provider.
|
|
10
|
+
3. Keep provider secrets in runtime environment variables, not in UI bundles.
|
|
11
|
+
4. Normalize results into exported completion models.
|
|
12
|
+
|
|
13
|
+
## Adapter Checklist
|
|
14
|
+
|
|
15
|
+
- Map provider-specific response IDs to `Completion.id`.
|
|
16
|
+
- Populate `durationMs` from measured execution time.
|
|
17
|
+
- Set `partitionKey` to your stable user/session key.
|
|
18
|
+
- Attach provider usage/cost metadata to `usage`.
|
|
19
|
+
- Return strongly typed completion variants for each capability.
|
|
20
|
+
|
|
21
|
+
## Stability Notes
|
|
22
|
+
|
|
23
|
+
- `src/platform/openai.ts` and `src/platform/pixelverse.ts` are implementation
|
|
24
|
+
work areas and should be treated as provisional until explicit public export
|
|
25
|
+
and API freeze.
|
|
26
|
+
- Prefer composition from host apps until adapter APIs are finalized.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
type,github_handle,full_name,company,email,date,approver
|
package/legal/CLA.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Contributor License Agreements (CLA)
|
|
2
|
+
|
|
3
|
+
To protect the intellectual property of this project and ensure clarity of rights, all contributors must sign a Contributor License Agreement (CLA) before their first contribution.
|
|
4
|
+
|
|
5
|
+
## Which CLA should I sign?
|
|
6
|
+
|
|
7
|
+
- **Individual CLA**: If you are contributing personally and not on behalf of an employer, sign the [Individual CLA](INDIVIDUAL_CLA.md).
|
|
8
|
+
- **Corporate CLA**: If you are contributing as part of your work for a company, the company should sign the [Corporate CLA](CORPORATE_CLA.md).
|
|
9
|
+
|
|
10
|
+
## How to sign
|
|
11
|
+
|
|
12
|
+
1. Download the appropriate CLA file (Individual or Corporate).
|
|
13
|
+
2. Fill in the required details, sign, and date it.
|
|
14
|
+
3. Email a PDF copy of the signed document to **[contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)** with subject: `CLA – Individual` or `CLA – Corporate`.
|
|
15
|
+
|
|
16
|
+
## Registry
|
|
17
|
+
|
|
18
|
+
All signed CLAs are logged internally in the CLA registry (`CLA-REGISTRY.csv`).
|
|
19
|
+
|
|
20
|
+
## Questions?
|
|
21
|
+
|
|
22
|
+
If you have any questions about which CLA to sign or how the process works, please email **[contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)**.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Corporate Contributor License Agreement (CLA)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This Corporate Contributor License Agreement ("Agreement") is intended to protect the intellectual property rights of the contributors and the project, ensure clear licensing terms for contributions, and maintain trust within the community. By signing this Agreement, the corporation agrees to the terms that facilitate the use, distribution, and modification of contributions under the project's licensing framework.
|
|
6
|
+
|
|
7
|
+
## Agreement
|
|
8
|
+
|
|
9
|
+
1. **Representation of Authority**
|
|
10
|
+
The undersigned individual represents and warrants that they have the full legal authority to enter into this Agreement on behalf of the corporation named below ("Corporation") and to grant the rights contained herein.
|
|
11
|
+
|
|
12
|
+
2. **Grant of Copyright License**
|
|
13
|
+
The Corporation hereby grants to the project maintainers and users a perpetual, worldwide, non-exclusive, royalty-free, irrevocable copyright license to use, reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute the contributions submitted to the project.
|
|
14
|
+
|
|
15
|
+
3. **Grant of Patent License**
|
|
16
|
+
The Corporation hereby grants to the project maintainers and users a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under any patent claims that are necessarily infringed by the contributions to make, use, sell, offer for sale, import, and otherwise dispose of the contributions or derivative works thereof.
|
|
17
|
+
|
|
18
|
+
4. **Warranties and Representations**
|
|
19
|
+
The Corporation represents and warrants that:
|
|
20
|
+
|
|
21
|
+
- The contributions are the original work of the Corporation or that the Corporation has sufficient rights to grant the licenses herein.
|
|
22
|
+
- The submission of the contributions does not violate any agreements or rights of third parties.
|
|
23
|
+
|
|
24
|
+
5. **No Revocation**
|
|
25
|
+
This license is granted on a perpetual basis and cannot be revoked, provided that the terms of this Agreement are met.
|
|
26
|
+
|
|
27
|
+
6. **Governing Law**
|
|
28
|
+
This Agreement shall be governed by and construed in accordance with the laws of the United Kingdom, without regard to its conflict of laws principles.
|
|
29
|
+
|
|
30
|
+
7. **Execution**
|
|
31
|
+
|
|
32
|
+
This Agreement is effective upon signature by the authorized representative of the Corporation. Please sign and date this document, then email a scanned PDF copy to [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk).
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
### **@plasius/api**
|
|
37
|
+
|
|
38
|
+
**Corporation Legal Name:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
39
|
+
|
|
40
|
+
**Authorized Representative:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
41
|
+
|
|
42
|
+
**Title:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
43
|
+
|
|
44
|
+
**Email:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
45
|
+
|
|
46
|
+
**Date:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
47
|
+
|
|
48
|
+
**Signature:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## How to Sign
|
|
53
|
+
|
|
54
|
+
- Download this file as a template.
|
|
55
|
+
- Fill in the Corporation’s legal name, authorized representative, title, email, date, and provide a signature.
|
|
56
|
+
- Sign and date the document.
|
|
57
|
+
- Send a scanned copy of the signed Agreement to [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk).
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Individual Contributor License Agreement (CLA)
|
|
2
|
+
|
|
3
|
+
**Project:** @plasius/api (Plasius LTD)
|
|
4
|
+
**Version:** 1.0 — 2025‑09‑12
|
|
5
|
+
**Contact:** [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Definitions
|
|
10
|
+
|
|
11
|
+
- **"You"** (or **"Contributor"**) means the individual signing this CLA and submitting Contributions to the Project.
|
|
12
|
+
- **"Contribution"** means any original work of authorship, including code, documentation, data, designs, or feedback that You submit to the Project in any form (e.g., pull request, issue comment, email, file upload).
|
|
13
|
+
- **"Project"** means the @plasius/api repositories and related materials owned or managed by **Plasius LTD**.
|
|
14
|
+
|
|
15
|
+
## 2. Copyright License Grant
|
|
16
|
+
|
|
17
|
+
You hereby grant to Plasius LTD a **perpetual, worldwide, non‑exclusive, transferable, sublicensable, royalty‑free, irrevocable** copyright license to:
|
|
18
|
+
|
|
19
|
+
- use, reproduce, publicly display, publicly perform, modify, create derivative works of, and
|
|
20
|
+
- distribute Contributions in source and object form,
|
|
21
|
+
- and to **sublicense** these rights under any terms Plasius LTD chooses, including proprietary or open‑source licenses.
|
|
22
|
+
|
|
23
|
+
## 3. Patent License Grant
|
|
24
|
+
|
|
25
|
+
You hereby grant to Plasius LTD and its sublicensees a **perpetual, worldwide, non‑exclusive, transferable, royalty‑free, irrevocable** patent license to **make, have made, use, offer to sell, sell, import, and otherwise transfer** the Contribution and derivative works thereof, where such license applies only to patent claims that You **own or control** and that would be infringed by Your Contribution or its combination with the Project.
|
|
26
|
+
|
|
27
|
+
## 4. Moral Rights & Attribution
|
|
28
|
+
|
|
29
|
+
To the maximum extent permitted by applicable law, You **waive** and agree not to assert any moral rights (e.g., rights of attribution or integrity) in or to the Contribution against Plasius LTD. Plasius LTD may, but is not required to, credit You.
|
|
30
|
+
|
|
31
|
+
## 5. Representations & Warranties
|
|
32
|
+
|
|
33
|
+
You represent that:
|
|
34
|
+
|
|
35
|
+
1. **Originality / Rights:** Each Contribution is Your original creation, or You have sufficient rights to submit it and grant the licenses above.
|
|
36
|
+
2. **No Confidential Info:** Contributions **do not** include confidential information or trade secrets of any third party.
|
|
37
|
+
3. **No Infringement:** To the best of Your knowledge, Contributions do not infringe any third‑party IP rights.
|
|
38
|
+
4. **Employment / Contractor Status:** If Your employer or a third party might claim rights in Your Contribution, You have obtained **written permission** to make the Contribution and grant these licenses (attach or reference below), or Your Contribution is made **outside the scope** of your employment and without using your employer’s confidential information or resources.
|
|
39
|
+
5. **Compliance:** You will follow the Project’s policies (e.g., Code of Conduct, Security Policy) and applicable laws.
|
|
40
|
+
|
|
41
|
+
## 6. Third‑Party Code
|
|
42
|
+
|
|
43
|
+
If Your Contribution includes code, data, or other material from a third party, You will **identify the material and its license** in the pull request or submission, and ensure it is **compatible** with the Project’s licensing model. You will not submit material subject to terms that require the Project to disclose proprietary source code (e.g., certain copyleft obligations) unless the Project has **pre‑approved** such inclusion in writing.
|
|
44
|
+
|
|
45
|
+
## 7. Scope & Duration
|
|
46
|
+
|
|
47
|
+
- This CLA covers **all past and future** Contributions You submit to the Project, unless and until You provide written notice to **revoke** it.
|
|
48
|
+
- Revocation is **not retroactive**: rights granted for prior Contributions remain in effect.
|
|
49
|
+
|
|
50
|
+
## 8. Disclaimer
|
|
51
|
+
|
|
52
|
+
THE CONTRIBUTION IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON‑INFRINGEMENT.
|
|
53
|
+
|
|
54
|
+
## 9. Governing Law & Jurisdiction
|
|
55
|
+
|
|
56
|
+
This CLA is governed by the **laws of England and Wales**, and the courts of England and Wales shall have **exclusive jurisdiction** over any dispute arising out of or relating to it.
|
|
57
|
+
|
|
58
|
+
## 10. Entire Agreement
|
|
59
|
+
|
|
60
|
+
This CLA is the entire agreement between You and Plasius LTD regarding Contributions. It supersedes any prior discussions relating to Contributions. If any provision is held unenforceable, the remaining provisions remain in full force.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 11. Contributor Information & Signature
|
|
65
|
+
|
|
66
|
+
By signing below, You agree to the terms of this CLA for Your Contributions to the Project.
|
|
67
|
+
|
|
68
|
+
**Full Name:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
69
|
+
|
|
70
|
+
**Email:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
71
|
+
|
|
72
|
+
**GitHub Handle:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
73
|
+
|
|
74
|
+
**Address (optional):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
75
|
+
|
|
76
|
+
**Employer (if applicable):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
77
|
+
|
|
78
|
+
**If employed:** ☐ I confirm Contributions are made outside the scope of employment **or** ☐ I have attached my employer’s written permission.
|
|
79
|
+
|
|
80
|
+
**Signature:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
81
|
+
|
|
82
|
+
**Date (YYYY‑MM‑DD):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
|
|
83
|
+
|
|
84
|
+
_Electronic signatures are accepted. You may type your name in the Signature field and email a PDF copy._
|
|
85
|
+
|
|
86
|
+
**Submission:** Please email the signed CLA to **[contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)** with subject line: `CLA – Individual – <GitHubHandle>`.
|
|
87
|
+
|
|
88
|
+
**(Optional) Attachments / Notes:**
|
|
89
|
+
|
|
90
|
+
- Employer permission letter (if required)
|
|
91
|
+
- Third‑party license disclosures (if any)
|
package/package.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plasius/ai",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Plasius AI functions providing chatbot, text-to-speech, speech-to-text, and AI-generated images and videos",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"chatbot",
|
|
7
|
+
"text-to-speech",
|
|
8
|
+
"speech-to-text",
|
|
9
|
+
"AI-generated images",
|
|
10
|
+
"AI-generated videos",
|
|
11
|
+
"Plasius AI"
|
|
12
|
+
],
|
|
13
|
+
"main": "./dist-cjs/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"private": false,
|
|
16
|
+
"type": "module",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc --build && npm run build:cjs",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:watch": "vitest",
|
|
21
|
+
"test:coverage": "vitest run --coverage",
|
|
22
|
+
"test:coverage:watch": "vitest --coverage",
|
|
23
|
+
"clean": "rimraf dist-cjs dist tsconfig.tsbuildinfo",
|
|
24
|
+
"reset:clean": "rm -rf node_modules package-lock.json && npm run clean",
|
|
25
|
+
"audit:ts": "tsc --noEmit --pretty",
|
|
26
|
+
"audit:eslint": "eslint \"{src,apps,packages}/**/*.{ts,tsx}\" --max-warnings=0 --ext .ts,.tsx",
|
|
27
|
+
"audit:deps": "depcheck --skip-missing=true",
|
|
28
|
+
"audit:npm": "npm audit --audit-level=moderate || true",
|
|
29
|
+
"audit:test": "vitest run --coverage",
|
|
30
|
+
"audit:all": "npm-run-all -l audit:ts audit:eslint audit:deps audit:npm audit:test",
|
|
31
|
+
"build:cjs": "tsc -p tsconfig.json --module commonjs --moduleResolution node --outDir dist-cjs --tsBuildInfoFile dist-cjs/tsconfig.tsbuildinfo",
|
|
32
|
+
"lint": "eslint .",
|
|
33
|
+
"prepare": "npm run build"
|
|
34
|
+
},
|
|
35
|
+
"author": "Plasius LTD <development@plasius.co.uk>",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@plasius/entity-manager": "^1.0.4",
|
|
39
|
+
"@plasius/error": "^1.0.0",
|
|
40
|
+
"@plasius/profile": "^1.0.0",
|
|
41
|
+
"@plasius/schema": "^1.0.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"openai": "^5.19.1",
|
|
45
|
+
"react": "^19.1.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@testing-library/react": "^16.3.0",
|
|
49
|
+
"@types/node": "^24.3.1",
|
|
50
|
+
"@types/react": "^19.1.8",
|
|
51
|
+
"@types/uuid": "^10.0.0",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
53
|
+
"@typescript-eslint/parser": "^8.38.0",
|
|
54
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
55
|
+
"ajv": "^6.12.6",
|
|
56
|
+
"depcheck": "^1.4.7",
|
|
57
|
+
"eslint": "^9.33.0",
|
|
58
|
+
"npm-run-all": "^4.1.5",
|
|
59
|
+
"openai": "^5.19.1",
|
|
60
|
+
"react": "19.1.0",
|
|
61
|
+
"react-dom": "19.1.0",
|
|
62
|
+
"react-router-dom": "^7.6.2",
|
|
63
|
+
"tsx": "^4.20.3",
|
|
64
|
+
"typescript": "^5.8.3",
|
|
65
|
+
"vitest": "^3.2.4",
|
|
66
|
+
"zod": "^4.1.5"
|
|
67
|
+
},
|
|
68
|
+
"sideEffects": [
|
|
69
|
+
"*.css"
|
|
70
|
+
],
|
|
71
|
+
"exports": {
|
|
72
|
+
".": {
|
|
73
|
+
"types": "./dist/index.d.ts",
|
|
74
|
+
"import": "./dist/index.js",
|
|
75
|
+
"require": "./dist-cjs/index.js"
|
|
76
|
+
},
|
|
77
|
+
"./package.json": "./package.json"
|
|
78
|
+
},
|
|
79
|
+
"module": "./dist/index.js",
|
|
80
|
+
"files": [
|
|
81
|
+
"dist",
|
|
82
|
+
"dist-cjs",
|
|
83
|
+
"src",
|
|
84
|
+
"README.md",
|
|
85
|
+
"CHANGELOG.md",
|
|
86
|
+
"LICENSE",
|
|
87
|
+
"SECURITY.md",
|
|
88
|
+
"CODE_OF_CONDUCT.md",
|
|
89
|
+
"CONTRIBUTORS.md",
|
|
90
|
+
"docs",
|
|
91
|
+
"legal"
|
|
92
|
+
],
|
|
93
|
+
"repository": {
|
|
94
|
+
"type": "git",
|
|
95
|
+
"url": "git+https://github.com/Plasius-LTD/ai.git"
|
|
96
|
+
},
|
|
97
|
+
"bugs": {
|
|
98
|
+
"url": "https://github.com/Plasius-LTD/ai/issues"
|
|
99
|
+
},
|
|
100
|
+
"homepage": "https://github.com/Plasius-LTD/ai#readme",
|
|
101
|
+
"publishConfig": {
|
|
102
|
+
"access": "public"
|
|
103
|
+
},
|
|
104
|
+
"funding": [
|
|
105
|
+
{
|
|
106
|
+
"type": "patreon",
|
|
107
|
+
"url": "https://www.patreon.com/c/plasiusltd/membership"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"type": "github",
|
|
111
|
+
"url": "https://github.com/sponsors/Plasius-LTD"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"engines": {
|
|
115
|
+
"node": ">=22.12"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { v4 as uuidv4 } from "uuid";
|
|
3
|
+
import styles from "./balance.module.css";
|
|
4
|
+
|
|
5
|
+
interface BalanceResponse {
|
|
6
|
+
account_id: number;
|
|
7
|
+
credit_monthly: number;
|
|
8
|
+
credit_package: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface BalanceApiResponse {
|
|
12
|
+
Resp?: BalanceResponse;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default function Balance({ apiKey }: { apiKey: string }) {
|
|
16
|
+
const [balance, setBalance] = useState<BalanceResponse | null>(null);
|
|
17
|
+
|
|
18
|
+
const fetchBalance = async (): Promise<void> => {
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch("/pixelapi/openapi/v2/account/balance", {
|
|
21
|
+
method: "GET",
|
|
22
|
+
headers: {
|
|
23
|
+
"API-KEY": apiKey,
|
|
24
|
+
"AI-trace-ID": uuidv4(),
|
|
25
|
+
Accept: "application/json",
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
},
|
|
28
|
+
referrerPolicy: "no-referrer",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
console.error("Failed to fetch balance:", response.status, response.statusText);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const data = (await response.json()) as unknown as BalanceApiResponse;
|
|
37
|
+
if (data?.Resp) {
|
|
38
|
+
setBalance(data.Resp);
|
|
39
|
+
}
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error("fetchBalance() error", err);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
void fetchBalance(); // initial load
|
|
47
|
+
const intervalId = setInterval(() => {
|
|
48
|
+
void fetchBalance();
|
|
49
|
+
}, 600000);
|
|
50
|
+
return () => clearInterval(intervalId);
|
|
51
|
+
}, [apiKey]);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className={styles.balance_container}>
|
|
55
|
+
{balance ? (
|
|
56
|
+
<div>
|
|
57
|
+
<p>Monthly Credit: {balance.credit_monthly}</p>
|
|
58
|
+
<p>Package Credit: {balance.credit_package}</p>
|
|
59
|
+
</div>
|
|
60
|
+
) : (
|
|
61
|
+
<p>Loading balance...</p>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import Balance from "./balance.js";
|
|
3
|
+
|
|
4
|
+
// --- Pixelverse API Calls ---
|
|
5
|
+
|
|
6
|
+
interface PixelverseEditorProps {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
onVideoGenerated?: (videoUrl: string) => void;
|
|
9
|
+
onImageUpload?: (imageUrl: string) => void;
|
|
10
|
+
prompt?: string;
|
|
11
|
+
onPromptChange?: (prompt: string) => void;
|
|
12
|
+
negative_prompt?: string;
|
|
13
|
+
onNegativePromptChange?: (negative_prompt: string) => void;
|
|
14
|
+
template_id?: string;
|
|
15
|
+
onTemplateIdChange?: (template_id: string) => void;
|
|
16
|
+
seed?: number;
|
|
17
|
+
onSeedChange?: (seed: number) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function PixelverseEditor({
|
|
21
|
+
apiKey,
|
|
22
|
+
onVideoGenerated,
|
|
23
|
+
prompt,
|
|
24
|
+
negative_prompt,
|
|
25
|
+
template_id,
|
|
26
|
+
seed,
|
|
27
|
+
}: PixelverseEditorProps) {
|
|
28
|
+
const [videoUrl, setVideoUrl] = useState("");
|
|
29
|
+
const [videoId, setVideoId] = useState<number | null>(null);
|
|
30
|
+
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
|
31
|
+
const [loading, setLoading] = useState(false);
|
|
32
|
+
const [videoStatus, setVideoStatus] = useState<number>(0);
|
|
33
|
+
|
|
34
|
+
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
35
|
+
if (e.target.files?.[0]) {
|
|
36
|
+
setSelectedFile(e.target.files[0]);
|
|
37
|
+
handleUploadProcess();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const handleRegenerate = () => {
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const handleUploadProcess = async () => {
|
|
45
|
+
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div>
|
|
50
|
+
<Balance apiKey={apiKey} />
|
|
51
|
+
{videoStatus === 0 && !selectedFile && (
|
|
52
|
+
<div>
|
|
53
|
+
<p>Drag/Drop or Click HERE to upload</p>
|
|
54
|
+
<input
|
|
55
|
+
title="Upload Image"
|
|
56
|
+
type="file"
|
|
57
|
+
accept=".jpg,.jpeg,.png,.webp"
|
|
58
|
+
onChange={handleFileChange}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
)}
|
|
62
|
+
{loading && <div>Loading...</div>}
|
|
63
|
+
{videoStatus === 0 && selectedFile && (
|
|
64
|
+
<button onClick={handleUploadProcess}>Start Upload</button>
|
|
65
|
+
)}
|
|
66
|
+
{videoStatus === 1 && (
|
|
67
|
+
<div>
|
|
68
|
+
<video src={videoUrl} controls />
|
|
69
|
+
<button onClick={handleRegenerate}>Regenerate</button>
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
}
|
package/src/global.d.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./platform/index.js";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|