@coderbabasi/shared 0.0.0-stage → 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CoderBaba
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.
@@ -0,0 +1,87 @@
1
+ export declare const ErrorCodes: {
2
+ readonly INVALID_CODE: "INVALID_CODE";
3
+ readonly CODE_EXPIRED: "CODE_EXPIRED";
4
+ readonly TOO_MANY_ATTEMPTS: "TOO_MANY_ATTEMPTS";
5
+ readonly QUOTA_EXCEEDED: "QUOTA_EXCEEDED";
6
+ readonly TRIAL_EXHAUSTED: "TRIAL_EXHAUSTED";
7
+ readonly TRIAL_TASK_CAPPED: "TRIAL_TASK_CAPPED";
8
+ readonly TRIAL_UNAVAILABLE: "TRIAL_UNAVAILABLE";
9
+ readonly MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED";
10
+ readonly RATE_LIMITED: "RATE_LIMITED";
11
+ readonly UNAUTHORIZED: "UNAUTHORIZED";
12
+ readonly BAD_REQUEST: "BAD_REQUEST";
13
+ readonly OFFLINE: "OFFLINE";
14
+ };
15
+ export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
16
+ export type ModelId = "fast" | "smart";
17
+ export type ModelInfo = {
18
+ id: ModelId;
19
+ label: string;
20
+ openrouterId: string;
21
+ anonAllowed: boolean;
22
+ };
23
+ /** Curated allowlist. Change ids here to retune the product. */
24
+ export declare const MODELS: readonly ModelInfo[];
25
+ export declare function findModel(id: string): ModelInfo | undefined;
26
+ export declare const DEFAULT_API_URL = "https://coderbaba.si";
27
+ export type ToolCall = {
28
+ id: string;
29
+ type: "function";
30
+ function: {
31
+ name: string;
32
+ arguments: string;
33
+ };
34
+ };
35
+ export type ChatMessage = {
36
+ role: "system" | "user" | "assistant" | "tool";
37
+ content: string | null;
38
+ tool_calls?: ToolCall[];
39
+ tool_call_id?: string;
40
+ };
41
+ export type ChatRequestBody = {
42
+ taskId: string;
43
+ model: string;
44
+ messages: ChatMessage[];
45
+ tools?: unknown[];
46
+ maxTokens?: number;
47
+ };
48
+ export type ErrorResponse = {
49
+ error: {
50
+ code: string;
51
+ message: string;
52
+ resetAt?: string;
53
+ };
54
+ };
55
+ export type AnonymousResponse = {
56
+ token: string;
57
+ deviceId: string;
58
+ triesLeft: number;
59
+ triesLimit: number;
60
+ };
61
+ export type VerifyResponse = {
62
+ token: string;
63
+ };
64
+ export type DailyUsage = {
65
+ usedUsd: number;
66
+ limitUsd: number;
67
+ percentLeft: number;
68
+ resetAt: string;
69
+ };
70
+ export type UsageResponse = {
71
+ type: "anonymous";
72
+ triesLeft: number;
73
+ triesLimit: number;
74
+ modelLocked: true;
75
+ } | {
76
+ type: "user";
77
+ plan: string;
78
+ email?: string;
79
+ daily: DailyUsage;
80
+ monthly: {
81
+ usedUsd: number;
82
+ limitUsd: number;
83
+ resetAt: string;
84
+ };
85
+ };
86
+ export declare function isErrorResponse(value: unknown): value is ErrorResponse;
87
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;;;;;;;;;CAab,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAErE,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvC,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,MAAM,EAAE,SAAS,SAAS,EAatC,CAAC;AAEF,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAQ3D;AAED,eAAO,MAAM,eAAe,yBAAyB,CAAC;AAEtD,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,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,43 @@
1
+ export const ErrorCodes = {
2
+ INVALID_CODE: "INVALID_CODE",
3
+ CODE_EXPIRED: "CODE_EXPIRED",
4
+ TOO_MANY_ATTEMPTS: "TOO_MANY_ATTEMPTS",
5
+ QUOTA_EXCEEDED: "QUOTA_EXCEEDED",
6
+ TRIAL_EXHAUSTED: "TRIAL_EXHAUSTED",
7
+ TRIAL_TASK_CAPPED: "TRIAL_TASK_CAPPED",
8
+ TRIAL_UNAVAILABLE: "TRIAL_UNAVAILABLE",
9
+ MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED",
10
+ RATE_LIMITED: "RATE_LIMITED",
11
+ UNAUTHORIZED: "UNAUTHORIZED",
12
+ BAD_REQUEST: "BAD_REQUEST",
13
+ OFFLINE: "OFFLINE",
14
+ };
15
+ /** Curated allowlist. Change ids here to retune the product. */
16
+ export const MODELS = [
17
+ {
18
+ id: "fast",
19
+ label: "Fast",
20
+ openrouterId: "google/gemini-2.5-flash",
21
+ anonAllowed: true,
22
+ },
23
+ {
24
+ id: "smart",
25
+ label: "Smart",
26
+ openrouterId: "anthropic/claude-sonnet-4.5",
27
+ anonAllowed: false,
28
+ },
29
+ ];
30
+ export function findModel(id) {
31
+ const needle = id.trim().toLowerCase();
32
+ return MODELS.find((model) => model.id === needle ||
33
+ model.label.toLowerCase() === needle ||
34
+ model.openrouterId.toLowerCase() === needle);
35
+ }
36
+ export const DEFAULT_API_URL = "https://coderbaba.si";
37
+ export function isErrorResponse(value) {
38
+ if (!value || typeof value !== "object")
39
+ return false;
40
+ const error = value.error;
41
+ return Boolean(error && typeof error.code === "string" && typeof error.message === "string");
42
+ }
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;IAC5B,iBAAiB,EAAE,mBAAmB;IAC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HANGED
@@ -1,6 +1,35 @@
1
1
  {
2
2
  "name": "@coderbabasi/shared",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Shared types, model ids, and error codes for CoderBaba",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/coderbabaroot/coderbaba.git",
9
+ "directory": "packages/shared"
10
+ },
11
+ "type": "module",
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "devDependencies": {
27
+ "typescript": "^5.9.3",
28
+ "vitest": "^3.2.4"
29
+ },
30
+ "scripts": {
31
+ "build": "tsc -p tsconfig.json",
32
+ "typecheck": "tsc -p tsconfig.json --noEmit",
33
+ "test": "vitest run --passWithNoTests"
34
+ }
6
35
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
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.