@intelligo-dev/cli 1.0.0-beta.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 +201 -0
- package/dist/bin.d.ts +14 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +149 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/add.d.ts +48 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +83 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/create.d.ts +33 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +61 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/doctor.d.ts +23 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +129 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/migrate-check.d.ts +44 -0
- package/dist/commands/migrate-check.d.ts.map +1 -0
- package/dist/commands/migrate-check.js +92 -0
- package/dist/commands/migrate-check.js.map +1 -0
- package/dist/commands/upgrade-check.d.ts +40 -0
- package/dist/commands/upgrade-check.d.ts.map +1 -0
- package/dist/commands/upgrade-check.js +91 -0
- package/dist/commands/upgrade-check.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +58 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +65 -0
- package/dist/manifest.js.map +1 -0
- package/dist/migrations-dir.d.ts +13 -0
- package/dist/migrations-dir.d.ts.map +1 -0
- package/dist/migrations-dir.js +25 -0
- package/dist/migrations-dir.js.map +1 -0
- package/dist/migrations.d.ts +41 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +99 -0
- package/dist/migrations.js.map +1 -0
- package/package.json +44 -0
- package/templates/admin-page/admin-page.tsx.tpl +56 -0
- package/templates/app-scaffold/assistant-route.ts.tpl +66 -0
- package/templates/app-scaffold/components.json.tpl +23 -0
- package/templates/app-scaffold/env.example.tpl +13 -0
- package/templates/app-scaffold/globals.css.tpl +329 -0
- package/templates/app-scaffold/i18n-navigation.ts.tpl +10 -0
- package/templates/app-scaffold/i18n-request.ts.tpl +51 -0
- package/templates/app-scaffold/i18n-routing.ts.tpl +13 -0
- package/templates/app-scaffold/intelligo.ts.tpl +84 -0
- package/templates/app-scaffold/layout.tsx.tpl +53 -0
- package/templates/app-scaffold/lib-utils.ts.tpl +6 -0
- package/templates/app-scaffold/messages-en-app.json.tpl +4 -0
- package/templates/app-scaffold/middleware.ts.tpl +11 -0
- package/templates/app-scaffold/next.config.mjs.tpl +19 -0
- package/templates/app-scaffold/package.json.tpl +42 -0
- package/templates/app-scaffold/plans.ts.tpl +43 -0
- package/templates/app-scaffold/postcss.config.mjs.tpl +7 -0
- package/templates/app-scaffold/sonner.tsx.tpl +50 -0
- package/templates/app-scaffold/theme-provider.tsx.tpl +28 -0
- package/templates/app-scaffold/tsconfig.json.tpl +12 -0
- package/templates/billing-page/billing-page.tsx.tpl +72 -0
- package/templates/manifest.json +116 -0
- package/templates/usage-page/usage-page.tsx.tpl +60 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations-dir.js","sourceRoot":"","sources":["../src/migrations-dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,iCAAiC;IACjC,oDAAoD;CAC5C,CAAC;AAEX,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,KAAK,MAAM,QAAQ,IAAI,mBAAmB,EAAE,CAAC;QAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACtC,IAAI,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration-chain inspection.
|
|
3
|
+
*
|
|
4
|
+
* Drizzle keeps two sources of truth: the `.sql` files on disk and
|
|
5
|
+
* `meta/_journal.json`, which is what `drizzle-kit migrate` actually
|
|
6
|
+
* reads. Nothing keeps them in step. In this repo the journal stopped
|
|
7
|
+
* at entry 11 while 39 files accumulated, so `migrate` silently
|
|
8
|
+
* applied a quarter of the chain and every environment was really
|
|
9
|
+
* provisioned by `drizzle-kit push` from `schema.ts` instead — which
|
|
10
|
+
* is how a migration shipped documenting a unique constraint on a
|
|
11
|
+
* column no migration created.
|
|
12
|
+
*
|
|
13
|
+
* The drift is invisible until someone provisions a database from the
|
|
14
|
+
* migrations, at which point it is a production incident rather than a
|
|
15
|
+
* CI failure. These helpers make it a check.
|
|
16
|
+
*/
|
|
17
|
+
export type JournalEntry = {
|
|
18
|
+
idx: number;
|
|
19
|
+
version: string;
|
|
20
|
+
when: number;
|
|
21
|
+
tag: string;
|
|
22
|
+
breakpoints: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type MigrationChain = {
|
|
25
|
+
dir: string;
|
|
26
|
+
/** `.sql` files present on disk, sorted by their numeric prefix. */
|
|
27
|
+
files: string[];
|
|
28
|
+
/** Tags drizzle-kit will actually apply, in order. */
|
|
29
|
+
journalTags: string[];
|
|
30
|
+
/** On disk but absent from the journal — `migrate` skips these. */
|
|
31
|
+
unregistered: string[];
|
|
32
|
+
/** In the journal but missing from disk — `migrate` fails on these. */
|
|
33
|
+
missing: string[];
|
|
34
|
+
};
|
|
35
|
+
export declare function readMigrationChain(dir: string): MigrationChain;
|
|
36
|
+
export type ChainProblem = {
|
|
37
|
+
level: "error" | "warn";
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
export declare function inspectMigrationChain(chain: MigrationChain): ChainProblem[];
|
|
41
|
+
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,oEAAoE;IACpE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,sDAAsD;IACtD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,mEAAmE;IACnE,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,uEAAuE;IACvE,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAMF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CA2B9D;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,cAAc,GAAG,YAAY,EAAE,CA4D3E"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration-chain inspection.
|
|
3
|
+
*
|
|
4
|
+
* Drizzle keeps two sources of truth: the `.sql` files on disk and
|
|
5
|
+
* `meta/_journal.json`, which is what `drizzle-kit migrate` actually
|
|
6
|
+
* reads. Nothing keeps them in step. In this repo the journal stopped
|
|
7
|
+
* at entry 11 while 39 files accumulated, so `migrate` silently
|
|
8
|
+
* applied a quarter of the chain and every environment was really
|
|
9
|
+
* provisioned by `drizzle-kit push` from `schema.ts` instead — which
|
|
10
|
+
* is how a migration shipped documenting a unique constraint on a
|
|
11
|
+
* column no migration created.
|
|
12
|
+
*
|
|
13
|
+
* The drift is invisible until someone provisions a database from the
|
|
14
|
+
* migrations, at which point it is a production incident rather than a
|
|
15
|
+
* CI failure. These helpers make it a check.
|
|
16
|
+
*/
|
|
17
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
function tagOf(file) {
|
|
20
|
+
return file.replace(/\.sql$/, "");
|
|
21
|
+
}
|
|
22
|
+
export function readMigrationChain(dir) {
|
|
23
|
+
const files = readdirSync(dir)
|
|
24
|
+
.filter((f) => f.endsWith(".sql"))
|
|
25
|
+
.sort();
|
|
26
|
+
let journalTags = [];
|
|
27
|
+
try {
|
|
28
|
+
const journal = JSON.parse(readFileSync(path.join(dir, "meta", "_journal.json"), "utf8"));
|
|
29
|
+
journalTags = (journal.entries ?? []).map((e) => e.tag);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// No journal at all is itself the maximal drift: every file is
|
|
33
|
+
// unregistered, which the caller reports.
|
|
34
|
+
journalTags = [];
|
|
35
|
+
}
|
|
36
|
+
const registered = new Set(journalTags);
|
|
37
|
+
const onDisk = new Set(files.map(tagOf));
|
|
38
|
+
return {
|
|
39
|
+
dir,
|
|
40
|
+
files,
|
|
41
|
+
journalTags,
|
|
42
|
+
unregistered: files.map(tagOf).filter((t) => !registered.has(t)),
|
|
43
|
+
missing: journalTags.filter((t) => !onDisk.has(t)),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function inspectMigrationChain(chain) {
|
|
47
|
+
const problems = [];
|
|
48
|
+
if (chain.files.length === 0) {
|
|
49
|
+
problems.push({ level: "error", message: `No .sql files in ${chain.dir}` });
|
|
50
|
+
return problems;
|
|
51
|
+
}
|
|
52
|
+
if (chain.missing.length > 0) {
|
|
53
|
+
problems.push({
|
|
54
|
+
level: "error",
|
|
55
|
+
message: `Journal references ${chain.missing.length} migration(s) that are not on disk ` +
|
|
56
|
+
`(drizzle-kit migrate will fail): ${chain.missing.join(", ")}`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (chain.unregistered.length > 0) {
|
|
60
|
+
problems.push({
|
|
61
|
+
level: "error",
|
|
62
|
+
message: `${chain.unregistered.length} of ${chain.files.length} migration files are not in ` +
|
|
63
|
+
`meta/_journal.json, so drizzle-kit migrate skips them: ` +
|
|
64
|
+
`${chain.unregistered.slice(0, 5).join(", ")}` +
|
|
65
|
+
(chain.unregistered.length > 5 ? ", …" : ""),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// Numbering problems. Two files sharing a prefix is worse than a
|
|
69
|
+
// gap: `migrate` orders by tag, so which one runs first depends on
|
|
70
|
+
// the rest of the filename rather than on intent.
|
|
71
|
+
const numbers = chain.files
|
|
72
|
+
.map((f) => Number.parseInt(f.slice(0, 4), 10))
|
|
73
|
+
.filter((n) => Number.isFinite(n));
|
|
74
|
+
const seen = new Map();
|
|
75
|
+
for (const n of numbers)
|
|
76
|
+
seen.set(n, (seen.get(n) ?? 0) + 1);
|
|
77
|
+
const duplicates = [...seen.entries()]
|
|
78
|
+
.filter(([, count]) => count > 1)
|
|
79
|
+
.map(([n]) => String(n).padStart(4, "0"));
|
|
80
|
+
if (duplicates.length > 0) {
|
|
81
|
+
problems.push({
|
|
82
|
+
level: "warn",
|
|
83
|
+
message: `Duplicate migration prefixes (apply order is filename-dependent): ${duplicates.join(", ")}`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const unique = [...new Set(numbers)].sort((a, b) => a - b);
|
|
87
|
+
for (let i = 1; i < unique.length; i++) {
|
|
88
|
+
const prev = unique[i - 1];
|
|
89
|
+
const cur = unique[i];
|
|
90
|
+
if (cur > prev + 1) {
|
|
91
|
+
problems.push({
|
|
92
|
+
level: "warn",
|
|
93
|
+
message: `Gap in migration numbering: ${String(prev).padStart(4, "0")} → ${String(cur).padStart(4, "0")}`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return problems;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAsB7B,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC;SAC3B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACjC,IAAI,EAAE,CAAC;IAEV,IAAI,WAAW,GAAa,EAAE,CAAC;IAC/B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CACxB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAC9B,CAAC;QAClC,WAAW,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,+DAA+D;QAC/D,0CAA0C;QAC1C,WAAW,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAA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AC;IAED,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAE,CAAC;QACvB,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;YACnB,QAAQ,CAAC,IAAI,CAAC;gBACZ,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,+BAA+B,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE;aAC1G,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intelligo-dev/cli",
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/intelligo-mn/framework.git",
|
|
8
|
+
"directory": "packages/cli"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/intelligo-mn/framework#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/intelligo-mn/framework/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"bin": {
|
|
16
|
+
"intelligo": "./dist/bin.js"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"pg": "^8.18.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^22.0.0",
|
|
29
|
+
"@types/pg": "^8.16.0",
|
|
30
|
+
"typescript": "^5.7.2"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"templates"
|
|
35
|
+
],
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"type-check": "tsc --noEmit",
|
|
41
|
+
"lint": "eslint .",
|
|
42
|
+
"build": "tsc -p tsconfig.build.json"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Intelligo operational console, mounted in your app.
|
|
3
|
+
*
|
|
4
|
+
* The screen itself ships from @intelligo-dev/admin so every deployment
|
|
5
|
+
* shows the same operational truth — a fork could quietly stop showing
|
|
6
|
+
* you unsettled executions. What is generated here is only the mount:
|
|
7
|
+
* the route, the authorization call, and your own page chrome
|
|
8
|
+
* (ADR-0002).
|
|
9
|
+
*
|
|
10
|
+
* Access is gated on PLATFORM_ADMIN_EMAILS, not on a workspace role.
|
|
11
|
+
* Workspace `owner` is per-tenant and every signup has one.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
getPlatformOverview,
|
|
16
|
+
listUnsettledExecutions,
|
|
17
|
+
listWorkspaces,
|
|
18
|
+
requireAdmin,
|
|
19
|
+
} from "@intelligo-dev/admin";
|
|
20
|
+
import { PlatformOverviewView } from "@intelligo-dev/admin/views";
|
|
21
|
+
|
|
22
|
+
import { composeIntelligo } from "@/lib/intelligo";
|
|
23
|
+
|
|
24
|
+
export const dynamic = "force-dynamic";
|
|
25
|
+
|
|
26
|
+
export default async function AdminPage() {
|
|
27
|
+
composeIntelligo();
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
await requireAdmin("admin.overview.viewed");
|
|
31
|
+
} catch {
|
|
32
|
+
return (
|
|
33
|
+
<main style={{ fontFamily: "system-ui", padding: "2rem" }}>
|
|
34
|
+
<h1>Admin</h1>
|
|
35
|
+
<p>Not authorized.</p>
|
|
36
|
+
</main>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const [overview, workspaces, unsettled] = await Promise.all([
|
|
41
|
+
getPlatformOverview(),
|
|
42
|
+
listWorkspaces(20),
|
|
43
|
+
listUnsettledExecutions(),
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<main style={{ fontFamily: "system-ui", padding: "2rem" }}>
|
|
48
|
+
<h1>Admin</h1>
|
|
49
|
+
<PlatformOverviewView
|
|
50
|
+
overview={overview}
|
|
51
|
+
workspaces={workspaces}
|
|
52
|
+
unsettled={unsettled}
|
|
53
|
+
/>
|
|
54
|
+
</main>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Your assistant endpoint, generated once and now yours.
|
|
3
|
+
*
|
|
4
|
+
* The shape is the point: whatever model call you put in the middle,
|
|
5
|
+
* it runs inside an execution — entitlement decided, worst-case cost
|
|
6
|
+
* held, usage settled, audit emitted. Swap `callModel` for a Mastra
|
|
7
|
+
* agent, an AI SDK call, or anything else and nothing around it
|
|
8
|
+
* changes (ADR-0003).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { requireWorkspace } from "@intelligo-dev/auth";
|
|
12
|
+
|
|
13
|
+
import { CAPABILITIES, composeIntelligo, executions } from "@/lib/intelligo";
|
|
14
|
+
|
|
15
|
+
export const maxDuration = 60;
|
|
16
|
+
|
|
17
|
+
async function callModel(prompt: string) {
|
|
18
|
+
// Replace this with your framework's call.
|
|
19
|
+
const inputTokens = Math.max(1, Math.ceil(prompt.length / 4));
|
|
20
|
+
return {
|
|
21
|
+
text: `Echo: ${prompt}`,
|
|
22
|
+
usage: { inputTokens, outputTokens: inputTokens * 2 },
|
|
23
|
+
model: "example/echo-1",
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function POST(request: Request) {
|
|
28
|
+
composeIntelligo();
|
|
29
|
+
|
|
30
|
+
const body = (await request.json().catch(() => null)) as {
|
|
31
|
+
prompt?: unknown;
|
|
32
|
+
} | null;
|
|
33
|
+
if (!body || typeof body.prompt !== "string" || !body.prompt.trim()) {
|
|
34
|
+
return Response.json({ error: "prompt is required" }, { status: 400 });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let context;
|
|
38
|
+
try {
|
|
39
|
+
context = await requireWorkspace();
|
|
40
|
+
} catch {
|
|
41
|
+
return Response.json({ error: "unauthorized" }, { status: 401 });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const run = await executions.begin({
|
|
45
|
+
workspaceId: context.workspace.id,
|
|
46
|
+
userId: context.user.id,
|
|
47
|
+
capability: CAPABILITIES.assistantMessage,
|
|
48
|
+
model: "example/echo-1",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (!run.allowed) {
|
|
52
|
+
return Response.json(
|
|
53
|
+
{ error: run.reason ?? "quota exceeded", code: "QUOTA_EXCEEDED" },
|
|
54
|
+
{ status: 429 }
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const result = await callModel(body.prompt);
|
|
60
|
+
await run.complete({ usage: result.usage, model: result.model });
|
|
61
|
+
return Response.json({ text: result.text });
|
|
62
|
+
} catch (error) {
|
|
63
|
+
await run.fail({ error });
|
|
64
|
+
return Response.json({ error: "assistant failed" }, { status: 500 });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
+
"style": "new-york",
|
|
4
|
+
"rsc": true,
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"tailwind": {
|
|
7
|
+
"config": "",
|
|
8
|
+
"css": "app/globals.css",
|
|
9
|
+
"baseColor": "neutral",
|
|
10
|
+
"cssVariables": true,
|
|
11
|
+
"prefix": ""
|
|
12
|
+
},
|
|
13
|
+
"iconLibrary": "lucide",
|
|
14
|
+
"rtl": false,
|
|
15
|
+
"aliases": {
|
|
16
|
+
"components": "@/components",
|
|
17
|
+
"utils": "@/lib/utils",
|
|
18
|
+
"ui": "@/components/ui",
|
|
19
|
+
"lib": "@/lib",
|
|
20
|
+
"hooks": "@/hooks"
|
|
21
|
+
},
|
|
22
|
+
"registries": {}
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Required — the app will not boot without these.
|
|
2
|
+
DATABASE_URL=
|
|
3
|
+
BETTER_AUTH_SECRET=
|
|
4
|
+
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
|
5
|
+
|
|
6
|
+
# Which product's plans the billing engine bills against. Your
|
|
7
|
+
# composition root also sets this via setDefaultProductSlug(); the
|
|
8
|
+
# variable is here so CLI tooling can check it without booting the app.
|
|
9
|
+
INTELLIGO_BILLING_PRODUCT=__APP_SLUG__
|
|
10
|
+
|
|
11
|
+
# Comma-separated emails allowed to reach the Intelligo admin console.
|
|
12
|
+
# Closed by default: with no value, nobody is a platform admin.
|
|
13
|
+
PLATFORM_ADMIN_EMAILS=
|