@farero-ai/core 0.0.0-stage → 0.1.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Adluna AS
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 CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # Farero core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared API route contracts for the Farero PWA, server, and MCP tools. Other apps can import the contracts and route definitions from `@farero-ai/core/contracts` and `@farero-ai/core/routes`.
4
+
5
+ From the Farero checkout, `yarn pack:core` writes the npm tarball to `output/`. The release includes minified JavaScript, TypeScript declarations, and license information. The checkout builds its workspace copy with `yarn build:core`. A push to Farero's main branch that changes the packed files publishes the next patch release to npm. A change that breaks callers raises the minor version in this package's `package.json`.
@@ -0,0 +1,23 @@
1
+ /** Destinations understood by the existing Settings owner, including its section shortcuts. */
2
+ export declare const SETTINGS_SECTIONS: readonly ["general", "notifications", "interface", "theme", "providers", "models", "agents", "routing", "plugins", "prompts", "lantern", "feedback", "browser-cookies"];
3
+ export type SettingsSection = (typeof SETTINGS_SECTIONS)[number];
4
+ export declare function parseSettingsSection(value: unknown): SettingsSection | null;
5
+ export type FareroLink = {
6
+ kind: 'settings';
7
+ section: SettingsSection;
8
+ } | {
9
+ kind: 'role';
10
+ slug: string;
11
+ }
12
+ /** One entry of the signed plugin directory. Opening it shows the entry's review; it never installs. */
13
+ | {
14
+ kind: 'plugin';
15
+ id: string;
16
+ };
17
+ /** A plugin directory entry id as a link names it, or null. */
18
+ export declare function parsePluginEntryId(value: unknown): string | null;
19
+ /** Deliberate app destinations only. A deep link can never select a host or an arbitrary URL. */
20
+ export declare function parseFareroLink(value: string): FareroLink | null;
21
+ export declare function fareroDeepLink(link: FareroLink): string;
22
+ /** The renderer consumes the query through its Settings owner; no settings are changed by opening it. */
23
+ export declare function fareroAppRoute(link: FareroLink): string;
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var t=(r,n)=>c(r,"name",{value:n,configurable:!0});import{parseRoleTemplateLink as l,roleTemplateAppRoute as f,roleTemplateDeepLink as g}from"./role-template.js";const d=["general","notifications","interface","theme","providers","models","agents","routing","plugins","prompts","lantern","feedback","browser-cookies"];function o(r){return d.find(n=>n===r)??null}t(o,"parseSettingsSection");const m=/^(?=.{1,64}$)[a-z0-9]+(?:[.-][a-z0-9]+)*$/,h=/^farero:\/\/plugins\/([^/]*)\/?$/;function p(r){return typeof r=="string"&&m.test(r)?r:null}t(p,"parsePluginEntryId");function E(r){const n=l(r);if(n)return{kind:"role",slug:n};const i=p(h.exec(r.trim())?.[1]);if(i)return{kind:"plugin",id:i};try{const e=new URL(r.trim());if(e.protocol!=="farero:"||e.hostname!=="settings"||e.username||e.password||e.port||e.search||e.hash)return null;const s=e.pathname.match(/^(?:\/([a-z-]+))?\/?$/),u=s?o(s[1]??"general"):null;return u?{kind:"settings",section:u}:null}catch{return null}}t(E,"parseFareroLink");function a(r){if(!p(r))throw new Error("Plugin directory entry is invalid.");return r}t(a,"pluginEntryId");function I(r){if(r.kind==="role")return g(r.slug);if(r.kind==="plugin")return`farero://plugins/${a(r.id)}`;if(!o(r.section))throw new Error("Settings section is invalid.");return`farero://settings${r.section==="general"?"":`/${r.section}`}`}t(I,"fareroDeepLink");function L(r){if(r.kind==="role")return f(r.slug);if(r.kind==="plugin")return`/?plugin=${a(r.id)}`;if(!o(r.section))throw new Error("Settings section is invalid.");return`/?settings=${r.section}`}t(L,"fareroAppRoute");export{d as SETTINGS_SECTIONS,L as fareroAppRoute,I as fareroDeepLink,E as parseFareroLink,p as parsePluginEntryId,o as parseSettingsSection};
@@ -0,0 +1,212 @@
1
+ /** Native browser control is bound to one authenticated Desktop connection.
2
+ * Placement never grants control; admission follows browserPageAdmits. */
3
+ export interface BrowserScope {
4
+ deviceId: string;
5
+ connectionId: string;
6
+ workspaceId: string;
7
+ sessionId: string;
8
+ tabId: string;
9
+ }
10
+ export interface BrowserPageInfo {
11
+ tabId: string;
12
+ workspaceId: string;
13
+ /** Chat that created an agent page, or the chat that holds a user page's claim. */
14
+ sessionId?: string;
15
+ kind: 'agent' | 'user';
16
+ /** `agent` while sessionId holds the page; a user page with `user` is free to claim. */
17
+ control: 'agent' | 'user';
18
+ title: string;
19
+ url: string;
20
+ available: boolean;
21
+ }
22
+ /** One admission rule for discovery and execution. A chat controls its own agent
23
+ * pages and may claim any free user page in its workspace. A claim is exclusive
24
+ * until it ends, so another chat cannot take a page that is in use. */
25
+ export declare function browserPageAdmits(page: BrowserPageInfo, workspaceId: string, sessionId: string): boolean;
26
+ export interface BrowserToolDefinition {
27
+ name: string;
28
+ description?: string;
29
+ inputSchema: {
30
+ type: 'object';
31
+ properties?: Record<string, unknown>;
32
+ [key: string]: unknown;
33
+ };
34
+ }
35
+ /** The native adapter returns MCP content without encoding images into text. */
36
+ export interface BrowserToolResult {
37
+ content: Array<Record<string, unknown>>;
38
+ isError?: boolean;
39
+ structuredContent?: Record<string, unknown>;
40
+ [key: string]: unknown;
41
+ }
42
+ export interface BrowserReceipt {
43
+ id: string;
44
+ scope: BrowserScope;
45
+ fingerprint: string;
46
+ state: 'running' | 'done' | 'uncertain';
47
+ result?: BrowserToolResult;
48
+ }
49
+ export interface BrowserCommand {
50
+ id: string;
51
+ scope: BrowserScope;
52
+ fingerprint: string;
53
+ /** Only a sign-in request sends `sign-in-open`, once when it starts, and `sign-in-copy`, after the person's
54
+ * Continue. `sign-in-logins` and `sign-in-fill` belong to a saved-password sign-in. No agent route accepts
55
+ * any of these. A copy names its bound profile in `args.source`. A fill names a saved sign-in id, never a password. */
56
+ action: 'open' | 'close' | 'release' | 'tool' | 'sign-in-open' | 'sign-in-copy' | 'sign-in-logins' | 'sign-in-fill' | 'handoff';
57
+ url?: string;
58
+ tool?: string;
59
+ args?: Record<string, unknown>;
60
+ }
61
+ /** A Desktop names the commands it can run when it connects; an older host ignores the header. */
62
+ export declare const BROWSER_FEATURES_HEADER = "x-farero-browser-features";
63
+ /** The Desktop opens a sign-in page in the person's chosen browser and copies that site's cookies back. */
64
+ export declare const BROWSER_SIGN_IN_FEATURE = "sign-in";
65
+ /** The Desktop lists saved sign-ins for the page on screen and types the one the person allows. */
66
+ export declare const SAVED_SIGN_IN_FEATURE = "saved-sign-in";
67
+ /** The sign-in tool before handoff_request took its place. Older transcripts still show its card. */
68
+ export declare const BROWSER_SIGN_IN_TOOL = "browser_sign_in";
69
+ export type BrowserSignInState = 'waiting' | 'copying' | 'done' | 'failed' | 'cancelled';
70
+ export type BrowserSignInAction = 'continue' | 'cancel';
71
+ /** The browser profile on the tab's Desktop that the sign-in page opened in. Continue copies only from it. */
72
+ export interface BrowserSignInTarget {
73
+ /** The cookie source ID of the profile. */
74
+ source: string;
75
+ /** The browser and profile, in words for the person. */
76
+ label: string;
77
+ /** The site whose cookies, with its subdomains, Continue copies. */
78
+ site: string;
79
+ }
80
+ /** A chat asks the person to sign in to one site in their own browser, for a tab that the chat holds.
81
+ * Farero opens the page once in that browser. The person signs in there and presses Continue, and Farero
82
+ * copies that site's cookies into the tab. Neither Continue nor the copy proves that the sign-in worked:
83
+ * the chat checks the page. */
84
+ export interface BrowserSignIn {
85
+ id: string;
86
+ workspaceId: string;
87
+ sessionId: string;
88
+ deviceId: string;
89
+ tabId: string;
90
+ /** The sign-in page that Farero opens in the person's own browser. */
91
+ url: string;
92
+ /** The chat's words for the person. */
93
+ reason: string;
94
+ state: BrowserSignInState;
95
+ /** Farero's one open of the page: `pending` until the Desktop answers, `unopened` when it found the
96
+ * profile but could not start the browser, so the person opens the address there. */
97
+ open: 'pending' | 'opened' | 'unopened';
98
+ target?: BrowserSignInTarget;
99
+ createdAt: number;
100
+ continuedAt?: number;
101
+ /** When the request reached done, failed or cancelled. */
102
+ settledAt?: number;
103
+ /** What Continue copied. `site` is the domain whose cookies, with its subdomains, Farero read. */
104
+ copied?: {
105
+ site: string;
106
+ source: string;
107
+ imported: number;
108
+ omitted: number;
109
+ partial: boolean;
110
+ };
111
+ /** Why the request failed or ended, in words for the person and the chat. */
112
+ detail?: string;
113
+ }
114
+ /** The request that a browser_sign_in receipt names, in any provider's encoding of the result. */
115
+ export declare function browserSignInReceipt(output: unknown): string | undefined;
116
+ export interface BrowserDeviceConnection {
117
+ deviceId: string;
118
+ connectionId: string;
119
+ /** This host can retain protected tab identities independently of Desktop. */
120
+ privateHandoffs?: boolean;
121
+ }
122
+ export interface BrowserDeviceState {
123
+ pages: BrowserPageInfo[];
124
+ tools: BrowserToolDefinition[];
125
+ /** Exact revocations applied locally, acknowledged only after old grants end. */
126
+ acknowledgedRevocations?: BrowserRevocation[];
127
+ }
128
+ export interface BrowserRevocation {
129
+ sessionId: string;
130
+ generation: string;
131
+ }
132
+ export interface BrowserDeviceInfo extends BrowserDeviceConnection {
133
+ name: string;
134
+ }
135
+ export interface BrowserPollReply {
136
+ command: BrowserCommand | null;
137
+ /** A closed/archived/sandboxed chat must release grants and close its agent pages. */
138
+ revokedSessionIds: string[];
139
+ revocations?: BrowserRevocation[];
140
+ }
141
+ export type BrowserClaimReply = {
142
+ claimed: true;
143
+ } | {
144
+ claimed: false;
145
+ receipt: BrowserReceipt;
146
+ };
147
+ export declare const BROWSER_CONNECTION_HEADER = "x-farero-browser-connection";
148
+ /** All routes require the installation bearer and ordinary origin validation.
149
+ * Device routes also require deviceId query and the exact connection header. */
150
+ export declare const BROWSER_PATHS: {
151
+ readonly connect: "/api/browser/device/connect";
152
+ readonly state: "/api/browser/device/state";
153
+ readonly commands: "/api/browser/device/commands";
154
+ readonly authorize: "/api/browser/device/authorize";
155
+ readonly claim: "/api/browser/device/journal/claim";
156
+ readonly finish: "/api/browser/device/journal/finish";
157
+ readonly disconnect: "/api/browser/device/disconnect";
158
+ readonly devices: "/api/browser/devices";
159
+ readonly tabs: "/api/browser/tabs";
160
+ readonly operate: "/api/browser/operate";
161
+ readonly receipt: "/api/browser/receipt";
162
+ /** The person's view of one sign-in request, by `id` query. A chat starts one with handoff_request. */
163
+ readonly signIns: "/api/browser/sign-ins";
164
+ /** The person's Continue or Cancel. Agent callers are refused. */
165
+ readonly signInAction: "/api/browser/sign-ins/action";
166
+ /** The person's view of one saved-password sign-in, by `id` query. */
167
+ readonly savedSignIns: "/api/browser/saved-sign-ins";
168
+ /** The person's allow, remember, continue or cancel. Agent callers are refused. */
169
+ readonly savedSignInAction: "/api/browser/saved-sign-ins/action";
170
+ /** Saved-password grants on this computer. GET lists them. POST `{ id }` removes one. */
171
+ readonly passwordGrants: "/api/browser/password-grants";
172
+ };
173
+ /** How far a saved-password grant reaches. */
174
+ export type PasswordGrantScope = 'chat' | 'device';
175
+ /** One saved sign-in the person allowed Farero to fill again. The password stays in the browser profile. */
176
+ export interface PasswordGrant {
177
+ id: string;
178
+ origin: string;
179
+ username: string;
180
+ scope: PasswordGrantScope;
181
+ /** Set for a grant that lasts until this chat ends. */
182
+ sessionId?: string;
183
+ createdAt: number;
184
+ }
185
+ export type SavedSignInState = 'listing' | 'waiting' | 'filling' | 'finishing' | 'done' | 'failed' | 'cancelled';
186
+ export type SavedSignInAction = 'allow_once' | 'remember_chat' | 'remember_device' | 'continue' | 'cancel';
187
+ /** A username offered for the page. The password is read on the Desktop only when the person allows the fill. */
188
+ export interface SavedSignInLogin {
189
+ id: string;
190
+ username: string;
191
+ }
192
+ /** A chat asks the person to fill one saved sign-in into a tab the chat holds. Farero types it on this computer.
193
+ * The chat never receives the password. A remembered grant can fill a later request for the same page and username. */
194
+ export interface SavedSignIn {
195
+ id: string;
196
+ workspaceId: string;
197
+ sessionId: string;
198
+ deviceId: string;
199
+ tabId: string;
200
+ /** The chat's words for the person. */
201
+ reason: string;
202
+ state: SavedSignInState;
203
+ /** The page origin the Desktop read. Empty while Farero is still asking the Desktop. */
204
+ origin: string;
205
+ logins: SavedSignInLogin[];
206
+ /** The username the person picked, or the grant filled. */
207
+ username?: string;
208
+ createdAt: number;
209
+ settledAt?: number;
210
+ /** Why the request failed or what the person should do next. */
211
+ detail?: string;
212
+ }
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var o=(r,n)=>d(r,"name",{value:n,configurable:!0});function b(r,n,e){return r.workspaceId!==n||!r.tabId.startsWith(`preview:${n}:`)||!r.available?!1:r.kind==="agent"?r.control==="agent"&&r.sessionId===e:r.control==="agent"?r.sessionId===e:r.sessionId===void 0}o(b,"browserPageAdmits");const p="x-farero-browser-features",w="sign-in",u="saved-sign-in",E="browser_sign_in";function I(r){const n=o((e,s)=>{if(s>6)return;if(typeof e=="string")try{return n(JSON.parse(e),s+1)}catch{return}if(Array.isArray(e)){for(const a of e){const c=n(a,s+1);if(c)return c}return}if(!e||typeof e!="object")return;const i=e;if(i.isError)return;const t=i.signIn;return t&&typeof t.id=="string"&&/^bsi_[a-f\d]{64}$/.test(t.id)?t.id:n(i.structuredContent??i.content??i.text,s+1)},"read");return n(r,0)}o(I,"browserSignInReceipt");const _="x-farero-browser-connection",R={connect:"/api/browser/device/connect",state:"/api/browser/device/state",commands:"/api/browser/device/commands",authorize:"/api/browser/device/authorize",claim:"/api/browser/device/journal/claim",finish:"/api/browser/device/journal/finish",disconnect:"/api/browser/device/disconnect",devices:"/api/browser/devices",tabs:"/api/browser/tabs",operate:"/api/browser/operate",receipt:"/api/browser/receipt",signIns:"/api/browser/sign-ins",signInAction:"/api/browser/sign-ins/action",savedSignIns:"/api/browser/saved-sign-ins",savedSignInAction:"/api/browser/saved-sign-ins/action",passwordGrants:"/api/browser/password-grants"};export{_ as BROWSER_CONNECTION_HEADER,p as BROWSER_FEATURES_HEADER,R as BROWSER_PATHS,w as BROWSER_SIGN_IN_FEATURE,E as BROWSER_SIGN_IN_TOOL,u as SAVED_SIGN_IN_FEATURE,b as browserPageAdmits,I as browserSignInReceipt};