@xema/omni-protocol 0.1.0
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/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/design.d.ts +49 -0
- package/dist/design.js +27 -0
- package/dist/index.d.ts +894 -0
- package/dist/index.js +185 -0
- package/dist/testing.d.ts +62 -0
- package/dist/testing.js +294 -0
- package/dist/validation.d.ts +21 -0
- package/dist/validation.js +940 -0
- package/guide.md +2935 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vasu Inukollu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Omni-Protocol
|
|
2
|
+
|
|
3
|
+
The contract every provider adapter implements, and the checks that hold adapters to it.
|
|
4
|
+
|
|
5
|
+
A provider is one independently connected external system — a voice platform, a chat platform, a
|
|
6
|
+
mail platform. An adapter is the package speaking this contract for one provider. Omni composes
|
|
7
|
+
several providers into one agent-facing desktop and owns everything outside a provider's own
|
|
8
|
+
system.
|
|
9
|
+
|
|
10
|
+
## What is here
|
|
11
|
+
|
|
12
|
+
| Path | |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| `guide.md` | **The protocol.** Rules, shapes, and the reasoning behind them. |
|
|
15
|
+
| `src/index.ts` | The TypeScript declarations. |
|
|
16
|
+
| `src/validation.ts` | Runtime validators Omni applies to adapter output. |
|
|
17
|
+
| `src/testing.ts` | Conformance helpers an adapter runs against its own test state. |
|
|
18
|
+
|
|
19
|
+
## Entry points
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { defineAdapter } from "@xema/omni-protocol";
|
|
23
|
+
import { validateSnapshot, assertNoViolations } from "@xema/omni-protocol/validation";
|
|
24
|
+
import { exerciseAdapter } from "@xema/omni-protocol/testing";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Validation is not only for tests
|
|
28
|
+
|
|
29
|
+
An adapter is loaded from a separate package and may be compiled against a different protocol
|
|
30
|
+
version, so its output is untrusted input. Every validator takes `unknown` and returns every
|
|
31
|
+
violation it found rather than throwing on the first, so a caller reports all of them at once.
|
|
32
|
+
Validating a snapshot before it replaces provider state is what stops a malformed task reaching
|
|
33
|
+
the agent's workspace.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
const violations = validateSnapshot(snapshot, manifest);
|
|
37
|
+
assertNoViolations(violations);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
A violation carries a stable `rule` id such as `task.browser.url.scheme`, the `path` it was found
|
|
41
|
+
at such as `snapshot.tasks[0].browsers[1].url`, and a `message`.
|
|
42
|
+
|
|
43
|
+
## Conformance
|
|
44
|
+
|
|
45
|
+
`exerciseAdapter` validates the manifest, opens an authenticated session, connects, checks
|
|
46
|
+
required capability methods, subscribes, validates the snapshot and every delivered event, states
|
|
47
|
+
a capacity, then unsubscribes and disconnects.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const result = await exerciseAdapter(adapter, context, { collectOnly: true });
|
|
51
|
+
expect(result.violations).toEqual([]);
|
|
52
|
+
expect(result.disconnectWasClean).toBe(true);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Run the contract scenarios beside it — authentication restore and expiry, reconnect with missed
|
|
56
|
+
assignments, break denial and retry, command idempotency, wrap timeout, browser isolation.
|
|
57
|
+
|
|
58
|
+
> **Assert both directions.** Every helper rejects a violating input as well as accepting a
|
|
59
|
+
> conforming one. A suite that only asserts "this conforming case does not throw" passes unchanged
|
|
60
|
+
> if the helper is gutted, so pair every positive case with the violating twin.
|
|
61
|
+
|
|
62
|
+
## Building
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
pnpm install
|
|
66
|
+
pnpm build # emits dist/
|
|
67
|
+
pnpm test # type-checks the tests, then runs them
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## The guide is authoritative
|
|
71
|
+
|
|
72
|
+
Where `guide.md` and any code here disagree, the guide is right and the code is a defect. It has
|
|
73
|
+
been through review and is not edited casually.
|
package/dist/design.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type ThemePreference = "system" | "light" | "dark";
|
|
2
|
+
export type ResolvedTheme = Exclude<ThemePreference, "system">;
|
|
3
|
+
export type Density = "compact" | "comfortable" | "spacious";
|
|
4
|
+
/** Semantic values consumed by Omni's layout, independent of a CSS framework. */
|
|
5
|
+
export interface DesignTokens {
|
|
6
|
+
accent: string;
|
|
7
|
+
accentText: string;
|
|
8
|
+
surface: string;
|
|
9
|
+
surfaceMuted: string;
|
|
10
|
+
selected: string;
|
|
11
|
+
text: string;
|
|
12
|
+
mutedText: string;
|
|
13
|
+
border: string;
|
|
14
|
+
info: string;
|
|
15
|
+
success: string;
|
|
16
|
+
warning: string;
|
|
17
|
+
danger: string;
|
|
18
|
+
radius: string;
|
|
19
|
+
radiusLarge: string;
|
|
20
|
+
shadow: string;
|
|
21
|
+
controlFont: string;
|
|
22
|
+
controlWeight: string;
|
|
23
|
+
controlTracking: string;
|
|
24
|
+
controlHeight: string;
|
|
25
|
+
}
|
|
26
|
+
export type ControlKind = "button" | "icon-button" | "checkbox" | "input" | "textarea" | "select" | "tabs" | "menu" | "badge" | "card" | "progress";
|
|
27
|
+
export interface DesignLanguageManifest {
|
|
28
|
+
id: string;
|
|
29
|
+
displayName: string;
|
|
30
|
+
supportedThemes: ReadonlyArray<ResolvedTheme>;
|
|
31
|
+
supportedControls: ReadonlyArray<ControlKind>;
|
|
32
|
+
defaultDensity: Density;
|
|
33
|
+
}
|
|
34
|
+
export interface DesignLanguage {
|
|
35
|
+
manifest: DesignLanguageManifest;
|
|
36
|
+
tokens: Record<ResolvedTheme, DesignTokens>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A framework bridge can use any native control representation: an Angular
|
|
40
|
+
* component type, a React component, or an Omni DOM renderer. The protocol
|
|
41
|
+
* deliberately does not make one UI framework part of the ABI.
|
|
42
|
+
*/
|
|
43
|
+
export interface DesignLanguageAdapter<TControl = unknown> {
|
|
44
|
+
readonly language: DesignLanguage;
|
|
45
|
+
resolveControl(kind: ControlKind): TControl | Promise<TControl>;
|
|
46
|
+
}
|
|
47
|
+
export declare function defineDesignLanguage<TControl, T extends DesignLanguageAdapter<TControl>>(adapter: T): T;
|
|
48
|
+
/** Maps semantic tokens to the stable CSS custom properties understood by Omni. */
|
|
49
|
+
export declare function designTokenProperties(tokens: DesignTokens): Record<string, string>;
|
package/dist/design.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function defineDesignLanguage(adapter) {
|
|
2
|
+
return adapter;
|
|
3
|
+
}
|
|
4
|
+
/** Maps semantic tokens to the stable CSS custom properties understood by Omni. */
|
|
5
|
+
export function designTokenProperties(tokens) {
|
|
6
|
+
return {
|
|
7
|
+
"--omni-accent": tokens.accent,
|
|
8
|
+
"--omni-accent-text": tokens.accentText,
|
|
9
|
+
"--omni-surface": tokens.surface,
|
|
10
|
+
"--omni-surface-muted": tokens.surfaceMuted,
|
|
11
|
+
"--omni-selected": tokens.selected,
|
|
12
|
+
"--omni-text": tokens.text,
|
|
13
|
+
"--omni-muted-text": tokens.mutedText,
|
|
14
|
+
"--omni-border": tokens.border,
|
|
15
|
+
"--omni-info": tokens.info,
|
|
16
|
+
"--omni-success": tokens.success,
|
|
17
|
+
"--omni-warning": tokens.warning,
|
|
18
|
+
"--omni-danger": tokens.danger,
|
|
19
|
+
"--omni-radius": tokens.radius,
|
|
20
|
+
"--omni-radius-large": tokens.radiusLarge,
|
|
21
|
+
"--omni-shadow": tokens.shadow,
|
|
22
|
+
"--omni-control-font": tokens.controlFont,
|
|
23
|
+
"--omni-control-weight": tokens.controlWeight,
|
|
24
|
+
"--omni-control-tracking": tokens.controlTracking,
|
|
25
|
+
"--omni-control-height": tokens.controlHeight,
|
|
26
|
+
};
|
|
27
|
+
}
|