@app-vitals/agent-lib 0.16.0 → 0.16.2

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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * lib/default-specialty.ts
3
+ *
4
+ * The single source of truth for the platform's default agent type and the
5
+ * directory its type definitions are loaded from. Shared by admin's
6
+ * SpecialtyRegistry / account-agent-create and runtime's resolveTemplatesDir so
7
+ * they can never disagree.
8
+ *
9
+ * Defaults are the platform's own: the `specialist` type under the shipped
10
+ * `agent-types/` directory (present in the platform image at /app/agent-types).
11
+ * SHIPWRIGHT_DEFAULT_AGENT_TYPE and SHIPWRIGHT_SPECIALTIES_DIR override them.
12
+ */
13
+
14
+ import { join } from "node:path";
15
+
16
+ /** The universal fallback type, shipped under agent-types/. */
17
+ export const DEFAULT_SPECIALTY_NAME = "specialist";
18
+
19
+ /** The shipped agent-types/ directory (lib/ and agent-types/ are siblings). */
20
+ export const SHIPPED_AGENT_TYPES_DIR = join(
21
+ import.meta.dir,
22
+ "..",
23
+ "agent-types",
24
+ );
25
+
26
+ /** SHIPWRIGHT_DEFAULT_AGENT_TYPE when set and non-empty, else "specialist". */
27
+ export function resolveDefaultSpecialtyName(
28
+ env: Record<string, string | undefined> = process.env,
29
+ ): string {
30
+ return env.SHIPWRIGHT_DEFAULT_AGENT_TYPE || DEFAULT_SPECIALTY_NAME;
31
+ }
32
+
33
+ /** SHIPWRIGHT_SPECIALTIES_DIR when set and non-empty, else the shipped agent-types/. */
34
+ export function resolveSpecialtiesDir(
35
+ env: Record<string, string | undefined> = process.env,
36
+ ): string {
37
+ return env.SHIPWRIGHT_SPECIALTIES_DIR || SHIPPED_AGENT_TYPES_DIR;
38
+ }
@@ -0,0 +1,44 @@
1
+ import { describe, expect, it } from "bun:test";
2
+ import { existsSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import {
5
+ DEFAULT_SPECIALTY_NAME,
6
+ resolveDefaultSpecialtyName,
7
+ resolveSpecialtiesDir,
8
+ SHIPPED_AGENT_TYPES_DIR,
9
+ } from "./default-specialty.ts";
10
+
11
+ describe("default specialty resolution", () => {
12
+ it("defaults to the shipped specialist type", () => {
13
+ expect(DEFAULT_SPECIALTY_NAME).toBe("specialist");
14
+ expect(resolveDefaultSpecialtyName({})).toBe("specialist");
15
+ });
16
+
17
+ it("defaults the specialties dir to the shipped agent-types/ directory", () => {
18
+ expect(resolveSpecialtiesDir({})).toBe(SHIPPED_AGENT_TYPES_DIR);
19
+ expect(SHIPPED_AGENT_TYPES_DIR).toBe(
20
+ join(import.meta.dir, "..", "agent-types"),
21
+ );
22
+ expect(
23
+ existsSync(join(SHIPPED_AGENT_TYPES_DIR, "specialist", "manifest.yaml")),
24
+ ).toBe(true);
25
+ });
26
+
27
+ it("treats empty env values as unset", () => {
28
+ expect(
29
+ resolveDefaultSpecialtyName({ SHIPWRIGHT_DEFAULT_AGENT_TYPE: "" }),
30
+ ).toBe("specialist");
31
+ expect(resolveSpecialtiesDir({ SHIPWRIGHT_SPECIALTIES_DIR: "" })).toBe(
32
+ SHIPPED_AGENT_TYPES_DIR,
33
+ );
34
+ });
35
+
36
+ it("honours the env overrides", () => {
37
+ expect(
38
+ resolveDefaultSpecialtyName({ SHIPWRIGHT_DEFAULT_AGENT_TYPE: "base" }),
39
+ ).toBe("base");
40
+ expect(
41
+ resolveSpecialtiesDir({ SHIPWRIGHT_SPECIALTIES_DIR: "/tmp/types" }),
42
+ ).toBe("/tmp/types");
43
+ });
44
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-lib",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -31,6 +31,7 @@
31
31
  "./secret-env-vars": "./secret-env-vars.ts",
32
32
  "./default-account": "./default-account.ts",
33
33
  "./default-agent-env": "./default-agent-env.ts",
34
+ "./default-specialty": "./default-specialty.ts",
34
35
  "./sentry": "./sentry.ts",
35
36
  "./task-store-types": "./task-store-types.ts",
36
37
  "./web/*": "./web/*"