O.G.A.S. Русский

Methods of the platform services

The methods of the services of the platform: settings, languages, observation and the journal, sources, the door for programs, the assistant and the profile.

Introduction

The document is a part of the contract Exchange with the kernel: the methods of the functions of the platform used by the workshop and other parts. The levels of settings and languages — Settings, what the platform writes about itself — The make-up of the platform, 3.8. The refusal codes — Error codes.

1 Settings

The files of the levels belong to the function of settings (Settings, section 1). The level session is only the memory of the function, not a file.

2 Localization

At introduction (handshake) a function may declare locales — relative folders (functions/<id>/locales, modules/<id>/locales). The kernel gives them with the query core.locales. The function i18n does not go round the folders of its neighbours itself.

3 Observability

4 Sources

The function sources (The workshop, 5.6; threats — Protection, 3.14). It goes to the network with the system program curl, with the proxies and certificates the system sees, and only when it is asked. It reads the showcase of ogas.space only together with its signature by the site key (File formats, 21.5): if the signature does not hold or is missing, sources.search, sources.item and sources.platform refuse with source_signature_bad.

5 The door for the person's programs

The function gate is the door through which a program of the person (an OGAS SDK script, an editor) talks to the platform. The door is closed until the setting gate.door is open; closing breaks all connections through it. The function listens over TCP only on 127.0.0.1, the port is the setting gate.port (0 — a free one), at once — no more than gate.clients programs. Where the door is and its key, the function writes into the document data/gate.json (ogas.gate/1): { format, port, key }, port is null while the door is closed. The key is 32 random bytes in hexadecimal; it lives until it is replaced.

The first message of a connection is gate.hello { key, client? }: the right key — the answer { status: "ready" }, a wrong one or another first message — the refusal gate_unauthorized and a closed connection; silence longer than 10 seconds closes the connection; as many programs as the door lets in already — gate_busy. Then the requests of the program go to the kernel, like the requests of the window, and the events of the kernel come to it as the notification event. Not allowed — the refusal gate_not_allowed: the kernel methods except core.status, core.health and core.event.subscribe; the methods gate.* and those of the functions of the window — the ones core.status calls interactive; settings.set of a key gate.*; settings.reset without a key or of a key gate.*.

The methods of the function for the window:

6 The assistant

The function assistant is the assistant of the workshop: the person writes a task in words, and the network they connected builds programs and modules with the tools of the platform, checks and tries them, and says what it did. A network is a module with "role": "assistant_network" (the input request, the output reply); ready networks come with OGAS SDK in sdk/networks, the key of a network lies in .env of its module and does not get into the function of the assistant.

The access of a task is draft or extended. With draft the assistant changes only the drafts and modules it made itself (their list — data/assistant/own.json, ogas.assistant-own/1), and does not switch programs on. With extended — any programs and modules of the person except the networks of the assistant, and it switches programs on. In no access does the assistant have tools that read secrets, change settings or delete.

A task goes in its own thread: the network answers, the function carries out the tools it called and gives it their answers, until the network answers without tools. A task stops when it has spent assistant.max_steps calls of the network or assistant.task_budget tokens, and waits for assistant.task.go_on. A task is written after each step into data/assistant/tasks/<task_id>.json (ogas.assistant-task/1) and tells of itself with the event assistant.task.changed.

7 The profile

The function profile — the person's profile on ogas.space, their parcels, sendings and letters, and what the site says of people: the board of requests, reviews, known bugs, profiles. What guards against what — Protection, section 8; the documents — File formats, section 21. The function goes to the network with the system program curl: it sends only at the person's command, it reads at a command or at start if the setting profile.check_on_start is on. Everything it reads from the site is taken only with a signature by the site key that holds; otherwise — site_signature_bad.

The main key comes into a call as the code (code) or the key file (file — a path, password?) and is forgotten as soon as the call ends.