@nirmos/sdk 0.3.5 → 0.3.6

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/README.md CHANGED
@@ -12,8 +12,6 @@ pnpm add @nirmos/sdk
12
12
  import { Nirmos, NirmosError } from "@nirmos/sdk";
13
13
 
14
14
  const nirmos = new Nirmos({
15
- apiBaseUrl: "http://localhost:4001",
16
- runtimeBaseUrl: "http://localhost:4000",
17
15
  auth: { type: "api-key", key: process.env.NIRMOS_API_KEY! },
18
16
  });
19
17
 
@@ -28,6 +26,8 @@ const prompt = await nirmos.prompts.create({
28
26
  await nirmos.prompts.update(prompt.promptId, { name: "Support reply",slug:"support-reply",description: "Customer support" });
29
27
  ```
30
28
 
29
+ Omitting `apiBaseUrl` and `runtimeBaseUrl` uses `https://api.nirmos.com` and `https://runtime.nirmos.com`, respectively. Set either option to override its default for local or private deployments.
30
+
31
31
  For an API-hosted Better Auth browser session:
32
32
 
33
33
  ```ts
@@ -379,6 +379,11 @@ pnpm docs:sdk:check
379
379
  node --test apps/web/scripts/sdk/docs-examples.test.mjs
380
380
  ```
381
381
 
382
+ `pnpm --filter @nirmos/sdk pack` runs prepack: it builds the SDK, regenerates the
383
+ reference from the current package version and public TypeScript inventory, and
384
+ checks documentation before packing. Commit the generated reference with a release.
385
+ The documentation check also rejects a package/reference version mismatch.
386
+
382
387
  These checks use local/injected responses, with no provider quota. See the public
383
388
  installation and evaluation guides for complete environment, run and cleanup
384
389
  instructions. `evaluations.traceCandidates()` exposes public request IDs and
@@ -58,7 +58,7 @@ class Nirmos {
58
58
  const runtime = new transport_js_1.HttpTransport({
59
59
  ...common,
60
60
  runtime: true,
61
- baseUrl: normalizeBaseUrl(options.runtimeBaseUrl ?? "https://gateway.nirmos.com"),
61
+ baseUrl: normalizeBaseUrl(options.runtimeBaseUrl ?? "https://runtime.nirmos.com"),
62
62
  });
63
63
  const resources = (0, resources_js_1.managementResources)(api);
64
64
  this.permissions = resources.permissions;
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
4
  // Generated from package.json by scripts/generate-version.mjs.
5
- exports.SDK_VERSION = "0.3.5";
5
+ exports.SDK_VERSION = "0.3.6";
6
6
  //# sourceMappingURL=version.js.map
@@ -55,7 +55,7 @@ export class Nirmos {
55
55
  const runtime = new HttpTransport({
56
56
  ...common,
57
57
  runtime: true,
58
- baseUrl: normalizeBaseUrl(options.runtimeBaseUrl ?? "https://gateway.nirmos.com"),
58
+ baseUrl: normalizeBaseUrl(options.runtimeBaseUrl ?? "https://runtime.nirmos.com"),
59
59
  });
60
60
  const resources = managementResources(api);
61
61
  this.permissions = resources.permissions;
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "0.3.5";
1
+ export declare const SDK_VERSION = "0.3.6";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Generated from package.json by scripts/generate-version.mjs.
2
- export const SDK_VERSION = "0.3.5";
2
+ export const SDK_VERSION = "0.3.6";
3
3
  //# sourceMappingURL=version.js.map
@@ -0,0 +1,65 @@
1
+ // Generated from prompt-rollback.ts. Do not edit.
2
+ import { Nirmos } from "@nirmos/sdk";
3
+ /** Disposable management rollback example. No provider call is needed. */
4
+ export async function promptRollback(nirmos) {
5
+ const suffix = `rollback-${Date.now()}`;
6
+ const prompt = await nirmos.prompts.create({ name: suffix, slug: suffix });
7
+ const save = async (text, parentVersionId) => {
8
+ const version = await nirmos.prompts.versions.create(prompt.promptId, {
9
+ branchId: prompt.branchId,
10
+ parentVersionId,
11
+ commitMessage: text,
12
+ temperature: 0,
13
+ maxTokens: 64,
14
+ topP: 1,
15
+ messages: [
16
+ {
17
+ order: 0,
18
+ role: "system",
19
+ contentBlocks: [{ order: 0, type: "text", text }],
20
+ },
21
+ ],
22
+ });
23
+ if (!version.versionId)
24
+ throw new Error("Missing saved version ID");
25
+ return version.versionId;
26
+ };
27
+ const active = async (versionId, text) => {
28
+ const released = await nirmos.managedPrompts.retrieveActive(prompt.promptId, { cache: "reload" });
29
+ const rendered = await nirmos.managedPrompts.render(released, {});
30
+ if (released.version.id !== versionId ||
31
+ rendered.messages[0]?.content !== text)
32
+ throw new Error("Published content differs from the requested release");
33
+ console.log(rendered.messages[0].content);
34
+ };
35
+ try {
36
+ const v1 = await save("V1: Answer concisely.");
37
+ await nirmos.prompts.versions.publish(prompt.promptId, v1);
38
+ await active(v1, "V1: Answer concisely.");
39
+ const v2 = await save("V2: Include policy citations.", v1);
40
+ await nirmos.prompts.versions.publish(prompt.promptId, v2);
41
+ await active(v2, "V2: Include policy citations.");
42
+ const saved = await save("V3: Unpublished work.", v2);
43
+ await nirmos.prompts.versions.publish(prompt.promptId, v1);
44
+ await active(v1, "V1: Answer concisely.");
45
+ const branches = await nirmos.prompts.branches.list(prompt.promptId);
46
+ if (branches.items.find((branch) => branch.id === prompt.branchId)
47
+ ?.headVersionId !== saved)
48
+ throw new Error("Rollback changed the saved branch head");
49
+ await nirmos.prompts.versions.publish(prompt.promptId, v2);
50
+ await active(v2, "V2: Include policy citations.");
51
+ return { v1, v2, saved };
52
+ }
53
+ finally {
54
+ await nirmos.prompts.delete(prompt.promptId);
55
+ }
56
+ }
57
+ // NIRMOS_API_KEY=... node prompt-rollback.mjs (or run the .ts file with tsx).
58
+ if (process.env.NIRMOS_API_KEY) {
59
+ await promptRollback(new Nirmos({
60
+ auth: { type: "api-key", key: process.env.NIRMOS_API_KEY },
61
+ apiBaseUrl: process.env.NIRMOS_API_URL ?? "http://localhost:4001",
62
+ runtimeBaseUrl: process.env.NIRMOS_RUNTIME_URL ?? "http://localhost:4000",
63
+ maxRetries: 0,
64
+ }));
65
+ }
@@ -0,0 +1,76 @@
1
+ import { Nirmos } from "@nirmos/sdk";
2
+
3
+ /** Disposable management rollback example. No provider call is needed. */
4
+ export async function promptRollback(nirmos: Nirmos) {
5
+ const suffix = `rollback-${Date.now()}`;
6
+ const prompt = await nirmos.prompts.create({ name: suffix, slug: suffix });
7
+ const save = async (text: string, parentVersionId?: string) => {
8
+ const version = await nirmos.prompts.versions.create(prompt.promptId, {
9
+ branchId: prompt.branchId,
10
+ parentVersionId,
11
+ commitMessage: text,
12
+ temperature: 0,
13
+ maxTokens: 64,
14
+ topP: 1,
15
+ messages: [
16
+ {
17
+ order: 0,
18
+ role: "system",
19
+ contentBlocks: [{ order: 0, type: "text", text }],
20
+ },
21
+ ],
22
+ });
23
+ if (!version.versionId) throw new Error("Missing saved version ID");
24
+ return version.versionId;
25
+ };
26
+ const active = async (versionId: string, text: string) => {
27
+ const released = await nirmos.managedPrompts.retrieveActive(
28
+ prompt.promptId,
29
+ { cache: "reload" },
30
+ );
31
+ const rendered = await nirmos.managedPrompts.render(released, {});
32
+ if (
33
+ released.version.id !== versionId ||
34
+ rendered.messages[0]?.content !== text
35
+ )
36
+ throw new Error("Published content differs from the requested release");
37
+ console.log(rendered.messages[0].content);
38
+ };
39
+ try {
40
+ const v1 = await save("V1: Answer concisely.");
41
+ await nirmos.prompts.versions.publish(prompt.promptId, v1);
42
+ await active(v1, "V1: Answer concisely.");
43
+ const v2 = await save("V2: Include policy citations.", v1);
44
+ await nirmos.prompts.versions.publish(prompt.promptId, v2);
45
+ await active(v2, "V2: Include policy citations.");
46
+ const saved = await save("V3: Unpublished work.", v2);
47
+ await nirmos.prompts.versions.publish(prompt.promptId, v1);
48
+ await active(v1, "V1: Answer concisely.");
49
+ const branches = await nirmos.prompts.branches.list(prompt.promptId);
50
+ if (
51
+ branches.items.find((branch) => branch.id === prompt.branchId)
52
+ ?.headVersionId !== saved
53
+ )
54
+ throw new Error("Rollback changed the saved branch head");
55
+ await nirmos.prompts.versions.publish(prompt.promptId, v2);
56
+ await active(v2, "V2: Include policy citations.");
57
+ return { v1, v2, saved };
58
+ } finally {
59
+ await nirmos.prompts.delete(prompt.promptId);
60
+ }
61
+ }
62
+
63
+ // This example remains type-checkable without Node type dependencies.
64
+ declare const process: { env: Record<string, string | undefined> };
65
+
66
+ // NIRMOS_API_KEY=... node prompt-rollback.mjs (or run the .ts file with tsx).
67
+ if (process.env.NIRMOS_API_KEY) {
68
+ await promptRollback(
69
+ new Nirmos({
70
+ auth: { type: "api-key", key: process.env.NIRMOS_API_KEY },
71
+ apiBaseUrl: process.env.NIRMOS_API_URL ?? "http://localhost:4001",
72
+ runtimeBaseUrl: process.env.NIRMOS_RUNTIME_URL ?? "http://localhost:4000",
73
+ maxRetries: 0,
74
+ }),
75
+ );
76
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nirmos/sdk",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Official TypeScript SDK for the Nirmos AI platform.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "build": "node ./scripts/generate-version.mjs && node ./scripts/clean.mjs && tsc -p tsconfig.build.json && tsc -p tsconfig.cjs.json && node ./scripts/write-cjs-package.mjs && node ./scripts/generate-examples.mjs",
26
26
  "check-types": "tsc --noEmit",
27
27
  "lint": "eslint src tests --max-warnings 0",
28
- "prepack": "pnpm build",
28
+ "prepack": "pnpm build && pnpm --dir ../.. docs:sdk && pnpm --dir ../.. docs:sdk:check",
29
29
  "test": "node ./scripts/ensure-built.mjs && tsc -p examples/tsconfig.json && tsc -p tests/tsconfig.json && node --test tests/*.test.mjs"
30
30
  },
31
31
  "engines": {
package/src/client.ts CHANGED
@@ -138,7 +138,7 @@ export class Nirmos {
138
138
  ...common,
139
139
  runtime: true,
140
140
  baseUrl: normalizeBaseUrl(
141
- options.runtimeBaseUrl ?? "https://gateway.nirmos.com",
141
+ options.runtimeBaseUrl ?? "https://runtime.nirmos.com",
142
142
  ),
143
143
  });
144
144
  const resources = managementResources(api);
@@ -1,2 +1,2 @@
1
1
  // Generated from package.json by scripts/generate-version.mjs.
2
- export const SDK_VERSION = "0.3.5";
2
+ export const SDK_VERSION = "0.3.6";