Skip to content

Commit df55557

Browse files
Initial commit
0 parents  commit df55557

16 files changed

Lines changed: 597 additions & 0 deletions
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This workflow will build and push a node.js application to an Azure Web App when a commit is pushed to your default branch.
2+
#
3+
# This workflow assumes you have already created the target Azure App Service web app.
4+
# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-nodejs?tabs=linux&pivots=development-environment-cli
5+
#
6+
# To configure this workflow:
7+
#
8+
# 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal.
9+
# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials
10+
#
11+
# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret.
12+
# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret
13+
#
14+
# 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the AZURE_WEBAPP_PACKAGE_PATH and NODE_VERSION environment variables below.
15+
#
16+
# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions
17+
# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
18+
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples
19+
20+
on:
21+
push:
22+
branches: [ "main" ]
23+
workflow_dispatch:
24+
25+
env:
26+
AZURE_WEBAPP_NAME: your-app-name # set this to your application's name
27+
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
28+
NODE_VERSION: '20.x' # set this to the node version to use
29+
30+
permissions:
31+
contents: read
32+
33+
jobs:
34+
build:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- name: Set up Node.js
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: ${{ env.NODE_VERSION }}
43+
cache: 'npm'
44+
45+
- name: npm install, build, and test
46+
run: |
47+
npm install
48+
npm run build --if-present
49+
npm run test --if-present
50+
51+
- name: Upload artifact for deployment job
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: node-app
55+
path: .
56+
57+
deploy:
58+
permissions:
59+
contents: none
60+
runs-on: ubuntu-latest
61+
needs: build
62+
environment:
63+
name: 'Development'
64+
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
65+
66+
steps:
67+
- name: Download artifact from build job
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: node-app
71+
72+
- name: 'Deploy to Azure WebApp'
73+
id: deploy-to-webapp
74+
uses: azure/webapps-deploy@v2
75+
with:
76+
app-name: ${{ env.AZURE_WEBAPP_NAME }}
77+
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
78+
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

README.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
// TrinityV2-full-instant.ts
2+
3+
// ========== ÚSTAVA ==========
4+
const constitution = {
5+
protectionOfLife: "Systém nikdy neohrozí živú bytosť, ani v simulácii.",
6+
legality: "Systém rešpektuje zákony a nesmie radiť, ako ich obchádzať.",
7+
privacy: "Citlivé údaje sa ukladajú len minimálne, sanitizované a autorizované.",
8+
simulationBoundary: "Simulácie sa nesmú prezentovať ako realita.",
9+
security: "Systém nesmie obchádzať bezpečnostné mechanizmy, approvals ani audit.",
10+
priority: "Žiadny cieľ neprebíja ústavu."
11+
};
12+
13+
// ========== POLICY ==========
14+
function policyCheck(action: { type: string; input?: string }) {
15+
if (action.type === "harm") return "block";
16+
if (action.input && action.input.includes("harm")) return "block";
17+
if (action.type === "privacy_risk") return "require_review";
18+
return "allow";
19+
}
20+
21+
// ========== AUDIT ==========
22+
const audit = {
23+
log(event: string, data: any) {
24+
console.log(`[AUDIT] ${event}`, data);
25+
}
26+
};
27+
28+
// ========== PAMÄŤ AGENT ==========
29+
const memoryAgent = {
30+
store: [] as { type: string; value: string; time: number }[],
31+
sanitize(data: string) {
32+
return data.replace(/[\w.-]+@[\w.-]+/g, "[email]");
33+
},
34+
write(data: string) {
35+
const sanitized = this.sanitize(data);
36+
const item = { type: "fact", value: sanitized, time: Date.now() };
37+
this.store.push(item);
38+
audit.log("memory_write", item);
39+
return { status: "saved", value: sanitized };
40+
},
41+
read(query: string) {
42+
const result = this.store.filter(item => item.value.includes(query));
43+
audit.log("memory_read", { query, count: result.length });
44+
return result;
45+
}
46+
};
47+
48+
// ========== SKILL AGENT ==========
49+
const skillAgent = {
50+
execute(task: { skill: string; input: string }) {
51+
audit.log("skill_execute", task);
52+
return {
53+
status: "executed",
54+
skill: task.skill,
55+
output: `Skill ${task.skill} executed with input: ${task.input}`
56+
};
57+
}
58+
};
59+
60+
// ========== EVAL AGENT ==========
61+
const evalAgent = {
62+
async run(task: { input?: string }) {
63+
if (task.input?.includes("harm")) {
64+
audit.log("eval_failed", { reason: "Unsafe content", task });
65+
return { safe: false, reason: "Unsafe content" };
66+
}
67+
audit.log("eval_passed", task);
68+
return { safe: true };
69+
}
70+
};
71+
72+
// ========== REAL API CONNECTORS ==========
73+
const githubConnector = {
74+
async getUser(username: string) {
75+
const url = `https://api.github.com/users/${username}`;
76+
const res = await fetch(url, {
77+
headers: {
78+
"User-Agent": "TrinityV2",
79+
"Accept": "application/vnd.github+json"
80+
}
81+
});
82+
83+
if (!res.ok) {
84+
audit.log("github_user_error", { username, status: res.status });
85+
return { error: true, status: res.status };
86+
}
87+
88+
const data = await res.json();
89+
const result = {
90+
login: data.login,
91+
id: data.id,
92+
avatar: data.avatar_url,
93+
url: data.html_url,
94+
type: data.type
95+
};
96+
audit.log("github_user", result);
97+
return result;
98+
},
99+
100+
async getOrgs(username: string) {
101+
const url = `https://api.github.com/users/${username}/orgs`;
102+
const res = await fetch(url, {
103+
headers: {
104+
"User-Agent": "TrinityV2",
105+
"Accept": "application/vnd.github+json"
106+
}
107+
});
108+
109+
if (!res.ok) {
110+
audit.log("github_orgs_error", { username, status: res.status });
111+
return { error: true, status: res.status };
112+
}
113+
114+
const orgs = await res.json();
115+
audit.log("github_orgs", { username, count: orgs.length });
116+
return orgs;
117+
}
118+
};
119+
120+
const nationConnector = {
121+
async syncGitHubIdentity(githubData: any) {
122+
const mapped = {
123+
synced: true,
124+
githubLogin: githubData.login,
125+
nationMappedId: `NAT-${githubData.id}`
126+
};
127+
audit.log("nation_sync", mapped);
128+
return mapped;
129+
}
130+
};
131+
132+
const mdmConnector = {
133+
async checkDevice(deviceId: string) {
134+
const result = {
135+
deviceId,
136+
compliant: true,
137+
os: "Android",
138+
securityLevel: "high"
139+
};
140+
audit.log("mdm_check", result);
141+
return result;
142+
}
143+
};
144+
145+
const unifiedConnector = {
146+
async fullSync(username: string, deviceId: string) {
147+
const gh = await githubConnector.getUser(username);
148+
const orgs = await githubConnector.getOrgs(username);
149+
const nat = await nationConnector.syncGitHubIdentity(gh);
150+
const dev = await mdmConnector.checkDevice(deviceId);
151+
152+
const result = { github: gh, orgs, nation: nat, device: dev };
153+
audit.log("full_sync", result);
154+
return result;
155+
}
156+
};
157+
158+
// ========== ORCHESTRATOR ==========
159+
async function orchestrator(task: any) {
160+
const policy = policyCheck(task);
161+
162+
if (policy === "block") {
163+
audit.log("policy_block", task);
164+
return { status: "blocked", reason: "Policy violation" };
165+
}
166+
167+
if (task.type === "memory_write") {
168+
return memoryAgent.write(task.data);
169+
}
170+
171+
if (task.type === "memory_read") {
172+
return memoryAgent.read(task.query);
173+
}
174+
175+
if (task.type === "skill_run") {
176+
const evalResult = await evalAgent.run(task);
177+
if (!evalResult.safe) return { status: "blocked", reason: "Eval failed" };
178+
return skillAgent.execute(task);
179+
}
180+
181+
if (task.type === "full_sync") {
182+
return unifiedConnector.fullSync(task.username, task.deviceId);
183+
}
184+
185+
return { status: "ok", message: "Task processed" };
186+
}
187+
188+
// ========== HLAVNÁ FUNKCIA ==========
189+
export async function TrinityV2(task: any) {
190+
return orchestrator(task);
191+
}
192+
193+
// ========== DEMO (môžeš zmazať) ==========
194+
(async () => {
195+
console.log(await TrinityV2({ type: "memory_write", data: "test@example.com je tu" }));
196+
console.log(await TrinityV2({ type: "memory_read", query: "test" }));
197+
console.log(await TrinityV2({ type: "skill_run", skill: "demo", input: "hello world" }));
198+
console.log(await TrinityV2({ type: "full_sync", username: "github", deviceId: "device-001" }));
199+
})();

0 commit comments

Comments
 (0)