@cognolo/runtime 0.4.3 → 0.4.5
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/dist/agent.js +2 -1
- package/dist/cloud.d.ts +6 -1
- package/dist/cloud.js +9 -1
- package/dist/gate.d.ts +3 -0
- package/dist/gate.js +3 -1
- package/dist/route.js +17 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +13 -1
- package/package.json +71 -71
package/dist/agent.js
CHANGED
|
@@ -100,7 +100,8 @@ export async function previewOf(def, ctx, input) {
|
|
|
100
100
|
return def.preview ? await def.preview(ctx, input) : def.title;
|
|
101
101
|
}
|
|
102
102
|
catch (e) {
|
|
103
|
-
|
|
103
|
+
console.error(`Cognolo: the preview of ${def.name} threw`, e);
|
|
104
|
+
return `${def.title} (preview unavailable)`;
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
export async function runTurn(opts) {
|
package/dist/cloud.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface CloudOptions {
|
|
|
19
19
|
commit?: string;
|
|
20
20
|
/** The customer organisation shown in the badge, if the host knows it. */
|
|
21
21
|
tenant?: string | (() => string | undefined);
|
|
22
|
-
/** How many tools this app has, reported on the heartbeat. */
|
|
22
|
+
/** How many tools this app has, reported on the heartbeat. `cognoloRoute` reports the list itself (`reportTools`). */
|
|
23
23
|
toolCount?: number;
|
|
24
24
|
/** How old the rules may be before the next use checks for new ones. Default 30 seconds. */
|
|
25
25
|
intervalMs?: number;
|
|
@@ -271,6 +271,11 @@ export interface CognoloCloud<C = unknown> {
|
|
|
271
271
|
reportCredit(state: "shown" | "hidden"): void;
|
|
272
272
|
/** Whether the AI provider accepted the model key on the last call (`refused`: it turned it down). Told to the cloud with the next heartbeat (soon, if it changed). Never the key. */
|
|
273
273
|
reportModelKey?(state: "ok" | "refused"): void;
|
|
274
|
+
/** The tools this app has, by name and risk, for the owner's Tools page. Display only: the cloud decides nothing from it. */
|
|
275
|
+
reportTools?(tools: {
|
|
276
|
+
name: string;
|
|
277
|
+
risk: string;
|
|
278
|
+
}[]): void;
|
|
274
279
|
/**
|
|
275
280
|
* Check for rules once now, then send a heartbeat every `heartbeatMs` (and any waiting events), so the dashboard knows
|
|
276
281
|
* the app is alive. It never checks for rules on a timer: use does that. Does not keep the process alive. A server
|
package/dist/cloud.js
CHANGED
|
@@ -43,6 +43,7 @@ export function cognoloCloud(o) {
|
|
|
43
43
|
let modelKey = null;
|
|
44
44
|
let modelChoice = null;
|
|
45
45
|
let passkeys = null;
|
|
46
|
+
let toolList = null;
|
|
46
47
|
const unnamedReads = new Set();
|
|
47
48
|
let unnamedSeen = false;
|
|
48
49
|
const locked = o.lockLook === true ? LOOK_FIELDS : LOOK_FIELDS.filter((f) => o.lockLook?.includes(f));
|
|
@@ -93,7 +94,7 @@ export function cognoloCloud(o) {
|
|
|
93
94
|
await call("/v1/runtime/heartbeat", {
|
|
94
95
|
method: "POST",
|
|
95
96
|
headers: { "content-type": "application/json" },
|
|
96
|
-
body: JSON.stringify({ env: o.env, commit: deployedCommit(o.commit), version: RUNTIME_VERSION, rulesVersion: bundle?.version ?? null, tools: o.toolCount ?? null, tenant: tenant ?? null, credit, lookLocked: locked, layouts, modelKey, modelChoice, ...(passkeys ? { passkeys } : {}), ...(unnamedSeen ? { outsideUnnamed: [...unnamedReads].sort() } : {}) }),
|
|
97
|
+
body: JSON.stringify({ env: o.env, commit: deployedCommit(o.commit), version: RUNTIME_VERSION, rulesVersion: bundle?.version ?? null, tools: toolList?.length ?? o.toolCount ?? null, ...(toolList ? { toolList } : {}), tenant: tenant ?? null, credit, lookLocked: locked, layouts, modelKey, modelChoice, ...(passkeys ? { passkeys } : {}), ...(unnamedSeen ? { outsideUnnamed: [...unnamedReads].sort() } : {}) }),
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
catch { }
|
|
@@ -361,6 +362,13 @@ export function cognoloCloud(o) {
|
|
|
361
362
|
modelChoice = state;
|
|
362
363
|
void (beating ?? Promise.resolve()).then(beat);
|
|
363
364
|
},
|
|
365
|
+
reportTools(tools) {
|
|
366
|
+
const next = tools.filter((t) => /^[A-Za-z0-9_.-]{1,128}$/.test(t.name)).slice(0, 500).map((t) => ({ name: t.name, risk: t.risk })).sort((x, y) => x.name.localeCompare(y.name));
|
|
367
|
+
if (JSON.stringify(next) === JSON.stringify(toolList))
|
|
368
|
+
return;
|
|
369
|
+
toolList = next;
|
|
370
|
+
void (beating ?? Promise.resolve()).then(beat);
|
|
371
|
+
},
|
|
364
372
|
reportModelKey(state) {
|
|
365
373
|
if (state === modelKey)
|
|
366
374
|
return;
|
package/dist/gate.d.ts
CHANGED
|
@@ -34,6 +34,9 @@ export declare const split: (v: Verdict) => {
|
|
|
34
34
|
};
|
|
35
35
|
export declare const canon: (v: unknown) => string;
|
|
36
36
|
export declare function summarize(outcome: ToolOutcome): string;
|
|
37
|
+
/** Said to the model when a tool's function crashes. A thrown error's own text can carry the values a query used (a database
|
|
38
|
+
* error), so it stays in the app's server log, as a Next.js form action shows the person only a digest (Fable, Dec 5 2026). */
|
|
39
|
+
export declare const TOOL_CRASHED = "The app hit an error while doing this, so it may not have finished. Don't try again; tell the person it didn't work and that the app's developer can see the error in the server log.";
|
|
37
40
|
export declare function runTool<C>(def: ToolDef<C>, ctx: C, input: unknown): Promise<ToolOutcome>;
|
|
38
41
|
export declare const ran: (def: {
|
|
39
42
|
name: string;
|
package/dist/gate.js
CHANGED
|
@@ -27,12 +27,14 @@ export function summarize(outcome) {
|
|
|
27
27
|
return d.summary;
|
|
28
28
|
return "Done";
|
|
29
29
|
}
|
|
30
|
+
export const TOOL_CRASHED = "The app hit an error while doing this, so it may not have finished. Don't try again; tell the person it didn't work and that the app's developer can see the error in the server log.";
|
|
30
31
|
export async function runTool(def, ctx, input) {
|
|
31
32
|
try {
|
|
32
33
|
return await def.run(ctx, input);
|
|
33
34
|
}
|
|
34
35
|
catch (e) {
|
|
35
|
-
|
|
36
|
+
console.error(`Cognolo: the tool ${def.name} threw`, e);
|
|
37
|
+
return { ok: false, error: TOOL_CRASHED, threw: true };
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
export const ran = (def, input, outcome) => ({ kind: "ran", tool: def.name, title: def.title, risk: def.risk, input, ok: outcome.ok, ...(!outcome.ok && outcome.threw ? { threw: true } : {}), summary: summarize(outcome), data: outcome.ok ? outcome.data : undefined });
|
package/dist/route.js
CHANGED
|
@@ -412,7 +412,7 @@ export function cognoloRoute(o) {
|
|
|
412
412
|
if (pkOrigins.length && ((from !== null && !pkOrigins.includes(from)) || (site !== null && site !== "same-origin")))
|
|
413
413
|
return json({ error: PASSKEY_NOT_HERE }, 403);
|
|
414
414
|
try {
|
|
415
|
-
const opened = await
|
|
415
|
+
const opened = await open(req, await rc.params);
|
|
416
416
|
if (notSetUp())
|
|
417
417
|
return json({ error: NOT_SET_UP }, 503);
|
|
418
418
|
if (!o.passkeys || !pkOrigins.length)
|
|
@@ -446,6 +446,19 @@ export function cognoloRoute(o) {
|
|
|
446
446
|
return fail(e);
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
|
+
const toolsSeen = new Map();
|
|
450
|
+
const open = async (req, params) => {
|
|
451
|
+
const x = await o.open(req, params);
|
|
452
|
+
let changed = false;
|
|
453
|
+
for (const t of x.tools)
|
|
454
|
+
if (toolsSeen.size < 500 && toolsSeen.get(t.name) !== t.risk) {
|
|
455
|
+
toolsSeen.set(t.name, t.risk);
|
|
456
|
+
changed = true;
|
|
457
|
+
}
|
|
458
|
+
if (changed)
|
|
459
|
+
o.cloud?.reportTools?.([...toolsSeen].map(([name, risk]) => ({ name, risk })));
|
|
460
|
+
return x;
|
|
461
|
+
};
|
|
449
462
|
const counter = outsideCounter({ counts: o.outsideCounts, env: o.env, onTrip: (t) => o.cloud?.reportFuse?.(t) });
|
|
450
463
|
const guardsNow = () => { const c = o.cloud?.protect?.(); return { hide: [...(o.protect?.hide ?? []), ...(c?.hide ?? [])], mask: [...(o.protect?.mask ?? []), ...(c?.mask ?? [])] }; };
|
|
451
464
|
const changesHere = () => !!o.passkeys && pkOrigins.length > 0 && !!o.passkey?.freshSignIn && !o.cloud?.passkey?.().clickOnly;
|
|
@@ -465,7 +478,7 @@ export function cognoloRoute(o) {
|
|
|
465
478
|
return no("Send { gate: { tool, input } }.", 400);
|
|
466
479
|
const via = "webmcp";
|
|
467
480
|
try {
|
|
468
|
-
const opened = await
|
|
481
|
+
const opened = await open(req, await rc.params);
|
|
469
482
|
const cloud = o.cloud;
|
|
470
483
|
if (!cloud?.outside)
|
|
471
484
|
return no(GATE_CANT);
|
|
@@ -744,7 +757,7 @@ export function cognoloRoute(o) {
|
|
|
744
757
|
if (!message && !Object.keys(decisions).length && !start && !make && !go && !ask && !send)
|
|
745
758
|
return json({ error: "Say something, or approve or decline the waiting actions." }, 400);
|
|
746
759
|
try {
|
|
747
|
-
const opened = await
|
|
760
|
+
const opened = await open(req, await rc.params);
|
|
748
761
|
if (notSetUp())
|
|
749
762
|
return json({ error: NOT_SET_UP }, 503);
|
|
750
763
|
const { scope } = opened;
|
|
@@ -1470,7 +1483,7 @@ export function cognoloRoute(o) {
|
|
|
1470
1483
|
};
|
|
1471
1484
|
async function GET(req, rc) {
|
|
1472
1485
|
try {
|
|
1473
|
-
const opened = await
|
|
1486
|
+
const opened = await open(req, await rc.params);
|
|
1474
1487
|
if (notSetUp())
|
|
1475
1488
|
return json({ badge: { ...badge(opened.tenant), notice: NOT_SET_UP } });
|
|
1476
1489
|
await o.cloud?.ready();
|
package/dist/version.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The runtime's version, reported to the cloud on every heartbeat. A test keeps it equal to package.json. */
|
|
2
|
-
export declare const RUNTIME_VERSION = "0.4.
|
|
2
|
+
export declare const RUNTIME_VERSION = "0.4.5";
|
|
3
3
|
/**
|
|
4
4
|
* The deployed git commit: the app's own setting, then `COGNOLO_COMMIT`, then a host's own variable (only a plain git hash
|
|
5
5
|
* counts from those). Null when nothing says, as when running on a developer's machine.
|
package/dist/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const RUNTIME_VERSION = "0.4.
|
|
1
|
+
export const RUNTIME_VERSION = "0.4.5";
|
|
2
2
|
const HOST_COMMIT_VARS = ["VERCEL_GIT_COMMIT_SHA", "RENDER_GIT_COMMIT", "RAILWAY_GIT_COMMIT_SHA", "COMMIT_REF", "CF_PAGES_COMMIT_SHA", "HEROKU_SLUG_COMMIT", "SOURCE_VERSION", "GITHUB_SHA"];
|
|
3
3
|
export function deployedCommit(own, env = typeof process === "undefined" ? {} : process.env) {
|
|
4
4
|
if (own)
|
|
@@ -14,6 +14,18 @@ export function deployedCommit(own, env = typeof process === "undefined" ? {} :
|
|
|
14
14
|
}
|
|
15
15
|
export const installSpec = (version) => `@cognolo/runtime@${version}`;
|
|
16
16
|
export const RELEASES = [
|
|
17
|
+
{
|
|
18
|
+
version: "0.4.5",
|
|
19
|
+
date: "2026-12-05",
|
|
20
|
+
summary: "When one of the app's tools crashes, the assistant is told only that the app hit an error, not the error's own text, which can hold the values a database query used. The error itself goes to the app's server log, where the developer can see it. A preview that fails says \"preview unavailable\" the same way.",
|
|
21
|
+
steps: ["Nothing to do beyond the usual update. To see why a tool failed, look in the app's server log, not the conversation."],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
version: "0.4.4",
|
|
25
|
+
date: "2026-12-04",
|
|
26
|
+
summary: "The app tells Cognolo which tools people have opened, by name and risk, so the owner's Tools page shows each tool running there, including ones written by hand. It is for display only and changes nothing about what any AI may do.",
|
|
27
|
+
steps: ["Nothing to do beyond the usual update."],
|
|
28
|
+
},
|
|
17
29
|
{
|
|
18
30
|
version: "0.4.3",
|
|
19
31
|
date: "2026-12-01",
|
package/package.json
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@cognolo/runtime",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "Cognolo's runtime: an AI assistant inside your own web app that acts through your app's own functions and permission checks, with a person approving changes.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"main": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"bin": {
|
|
13
|
-
"cognolo": "dist/init-cli.js"
|
|
14
|
-
},
|
|
15
|
-
"exports": {
|
|
16
|
-
".": {
|
|
17
|
-
"types": "./dist/index.d.ts",
|
|
18
|
-
"default": "./dist/index.js"
|
|
19
|
-
},
|
|
20
|
-
"./react": {
|
|
21
|
-
"types": "./dist/react/index.d.ts",
|
|
22
|
-
"default": "./dist/react/index.js"
|
|
23
|
-
},
|
|
24
|
-
"./setup": {
|
|
25
|
-
"types": "./dist/setup.d.ts",
|
|
26
|
-
"default": "./dist/setup.js"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"files": [
|
|
30
|
-
"dist",
|
|
31
|
-
"docs/store.md"
|
|
32
|
-
],
|
|
33
|
-
"sideEffects": false,
|
|
34
|
-
"engines": {
|
|
35
|
-
"node": ">=20"
|
|
36
|
-
},
|
|
37
|
-
"scripts": {
|
|
38
|
-
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json --removeComments && tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
39
|
-
"prepare": "npm run build",
|
|
40
|
-
"prepack": "npm run build",
|
|
41
|
-
"smoke": "node scripts/smoke.mjs",
|
|
42
|
-
"test": "tsx --import ./test/env.ts --test test/*.test.ts",
|
|
43
|
-
"eval": "tsx eval/run.ts",
|
|
44
|
-
"read": "tsx reader/cli.ts",
|
|
45
|
-
"answer": "tsx scripts/answer.ts",
|
|
46
|
-
"propose": "tsx reader/propose-cli.ts",
|
|
47
|
-
"github-app": "tsx github/serve.ts",
|
|
48
|
-
"typecheck": "tsc --noEmit"
|
|
49
|
-
},
|
|
50
|
-
"peerDependencies": {
|
|
51
|
-
"@anthropic-ai/sdk": "^1.6.0",
|
|
52
|
-
"zod": "^4.6.7",
|
|
53
|
-
"react": "^18.2.0 || ^19.0.0"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@anthropic-ai/sdk": "^1.6.0",
|
|
57
|
-
"@types/node": "^20",
|
|
58
|
-
"@types/react": "^19.3.0",
|
|
59
|
-
"@types/react-dom": "^19.3.0",
|
|
60
|
-
"react": "^19.3.1",
|
|
61
|
-
"react-dom": "^19.3.1",
|
|
62
|
-
"tsx": "^4.23.15",
|
|
63
|
-
"typescript": "^5",
|
|
64
|
-
"zod": "^4.6.7"
|
|
65
|
-
},
|
|
66
|
-
"peerDependenciesMeta": {
|
|
67
|
-
"react": {
|
|
68
|
-
"optional": true
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@cognolo/runtime",
|
|
3
|
+
"version": "0.4.5",
|
|
4
|
+
"description": "Cognolo's runtime: an AI assistant inside your own web app that acts through your app's own functions and permission checks, with a person approving changes.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"bin": {
|
|
13
|
+
"cognolo": "dist/init-cli.js"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./react": {
|
|
21
|
+
"types": "./dist/react/index.d.ts",
|
|
22
|
+
"default": "./dist/react/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./setup": {
|
|
25
|
+
"types": "./dist/setup.d.ts",
|
|
26
|
+
"default": "./dist/setup.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"docs/store.md"
|
|
32
|
+
],
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=20"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json --removeComments && tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
39
|
+
"prepare": "npm run build",
|
|
40
|
+
"prepack": "npm run build",
|
|
41
|
+
"smoke": "node scripts/smoke.mjs",
|
|
42
|
+
"test": "tsx --import ./test/env.ts --test test/*.test.ts",
|
|
43
|
+
"eval": "tsx eval/run.ts",
|
|
44
|
+
"read": "tsx reader/cli.ts",
|
|
45
|
+
"answer": "tsx scripts/answer.ts",
|
|
46
|
+
"propose": "tsx reader/propose-cli.ts",
|
|
47
|
+
"github-app": "tsx github/serve.ts",
|
|
48
|
+
"typecheck": "tsc --noEmit"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@anthropic-ai/sdk": "^1.6.0",
|
|
52
|
+
"zod": "^4.6.7",
|
|
53
|
+
"react": "^18.2.0 || ^19.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@anthropic-ai/sdk": "^1.6.0",
|
|
57
|
+
"@types/node": "^20",
|
|
58
|
+
"@types/react": "^19.3.0",
|
|
59
|
+
"@types/react-dom": "^19.3.0",
|
|
60
|
+
"react": "^19.3.1",
|
|
61
|
+
"react-dom": "^19.3.1",
|
|
62
|
+
"tsx": "^4.23.15",
|
|
63
|
+
"typescript": "^5",
|
|
64
|
+
"zod": "^4.6.7"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"react": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|