openvibers/openvibe.codes Commits
Codes C3: Codes reaches OpenVibe.AI's vault over the loopback (#169)
Changes
@@@ -66,7 +66,11 @@ function load(env = process.env) {// OpenVibe.AI (Codes C3): where a person's own provider key is sealed (it never leaves AI) and where the// harnesses run. Codes talks to it with its own Network token (audience openvibe.ai).ai: {++ // The public address: what a harness on the person's own machine is given.url: trim(env.CODES_AI_URL || 'https://ai.openvibe.services'),++ // Codes' own address for AI: the vault (a person's keys) is a host-local API, so Codes reaches it over++ // the loopback. The public address answers 403 there (nginx: /api/ is host-local only).++ internalUrl: trim(env.CODES_AI_INTERNAL_URL || 'http://127.0.0.1:4700'),audience: 'openvibe.ai',// The scopes Codes asks Network for: it stores a person's key with the first and runs a test request// (and the harnesses' requests) with the second.@@@ -49,7 +49,9 @@ function present(row) {}function createConnections({ config, fetchImpl = globalThis.fetch, log = console } = {}) {-- const base = String((config.ai && config.ai.url) || 'https://ai.openvibe.services').replace(/\/+$/, '');++ // Codes' own address for AI: the vault (a person's keys) is a host-local API, so Codes reaches it over the++ // loopback. The public address answers 403 there (nginx: /api/ is host-local only).++ const base = String((config.ai && (config.ai.internalUrl || config.ai.url)) || 'https://ai.openvibe.services').replace(/\/+$/, '');const scope = (config.ai && config.ai.scope) || 'ai.credential.manage ai.run.create';// Codes' own Network token for OpenVibe.AI: the consent grant (ai.credential.manage) lets it store a person's// key; ai.run.create lets it make the test request. Five minutes, cached by the SDK client.@@@ -14,7 +14,9 @@ const router = require('../engine/router');(async () => {const KEY = 'sk-ant-0123456789abcdefXYZ';-- const t = await boot({ env: (network) => ({ CODES_AI_URL: network.url }) });++ // The public address is an address that cannot answer (the vault is a host-local API): if Codes reached for it++ // instead of its own loopback address, every call here would fail.++ const t = await boot({ env: (network) => ({ CODES_AI_URL: 'https://ai.openvibe.services.invalid', CODES_AI_INTERNAL_URL: network.url }) });const db = t.ctx.store.db;const ada = t.network.addUser('ada');const bo = t.network.addUser('bo');
@@ -66,7 +66,11 @@ function load(env = process.env) {
@@ -66,7 +66,11 @@ function load(env = process.env) {
// OpenVibe.AI (Codes C3): where a person's own provider key is sealed (it never leaves AI) and where the
// OpenVibe.AI (Codes C3): where a person's own provider key is sealed (it never leaves AI) and where the
// harnesses run. Codes talks to it with its own Network token (audience openvibe.ai).
// harnesses run. Codes talks to it with its own Network token (audience openvibe.ai).
ai: {
ai: {
+ // The public address: what a harness on the person's own machine is given.
url: trim(env.CODES_AI_URL || 'https://ai.openvibe.services'),
url: trim(env.CODES_AI_URL || 'https://ai.openvibe.services'),
+ // Codes' own address for AI: the vault (a person's keys) is a host-local API, so Codes reaches it over
+ // the loopback. The public address answers 403 there (nginx: /api/ is host-local only).
+ internalUrl: trim(env.CODES_AI_INTERNAL_URL || 'http://127.0.0.1:4700'),
audience: 'openvibe.ai',
audience: 'openvibe.ai',
// The scopes Codes asks Network for: it stores a person's key with the first and runs a test request
// The scopes Codes asks Network for: it stores a person's key with the first and runs a test request
// (and the harnesses' requests) with the second.
// (and the harnesses' requests) with the second.
@@ -49,7 +49,9 @@ function present(row) {
@@ -49,7 +49,9 @@ function present(row) {
}
}
function createConnections({ config, fetchImpl = globalThis.fetch, log = console } = {}) {
function createConnections({ config, fetchImpl = globalThis.fetch, log = console } = {}) {
- const base = String((config.ai && config.ai.url) || 'https://ai.openvibe.services').replace(/\/+$/, '');
+ // Codes' own address for AI: the vault (a person's keys) is a host-local API, so Codes reaches it over the
+ // loopback. The public address answers 403 there (nginx: /api/ is host-local only).
+ const base = String((config.ai && (config.ai.internalUrl || config.ai.url)) || 'https://ai.openvibe.services').replace(/\/+$/, '');
const scope = (config.ai && config.ai.scope) || 'ai.credential.manage ai.run.create';
const scope = (config.ai && config.ai.scope) || 'ai.credential.manage ai.run.create';
// Codes' own Network token for OpenVibe.AI: the consent grant (ai.credential.manage) lets it store a person's
// Codes' own Network token for OpenVibe.AI: the consent grant (ai.credential.manage) lets it store a person's
// key; ai.run.create lets it make the test request. Five minutes, cached by the SDK client.
// key; ai.run.create lets it make the test request. Five minutes, cached by the SDK client.
@@ -14,7 +14,9 @@ const router = require('../engine/router');
@@ -14,7 +14,9 @@ const router = require('../engine/router');
(async () => {
(async () => {
const KEY = 'sk-ant-0123456789abcdefXYZ';
const KEY = 'sk-ant-0123456789abcdefXYZ';
- const t = await boot({ env: (network) => ({ CODES_AI_URL: network.url }) });
+ // The public address is an address that cannot answer (the vault is a host-local API): if Codes reached for it
+ // instead of its own loopback address, every call here would fail.
+ const t = await boot({ env: (network) => ({ CODES_AI_URL: 'https://ai.openvibe.services.invalid', CODES_AI_INTERNAL_URL: network.url }) });
const db = t.ctx.store.db;
const db = t.ctx.store.db;
const ada = t.network.addUser('ada');
const ada = t.network.addUser('ada');
const bo = t.network.addUser('bo');
const bo = t.network.addUser('bo');