psyche-ai 11.9.0 → 11.9.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.
@@ -34,6 +34,7 @@ import { serializeThrongletsExportAsTrace } from "../thronglets-runtime.js";
34
34
  import { resolveRelationshipUserId } from "../relationship-key.js";
35
35
  import { resolveAmbientPriorsForTurn, } from "../ambient-runtime.js";
36
36
  import { safeProcessInput, safeProcessOutput } from "./fail-open.js";
37
+ import { deriveThrongletsSpace } from "../thronglets-bridge.js";
37
38
  // ── Dimension description ────────────────────────────────────
38
39
  const DIM_THRESHOLDS = {
39
40
  high: 70,
@@ -118,7 +119,7 @@ export class PsycheClaudeSDK {
118
119
  thronglets: this.opts.ambient
119
120
  ? {
120
121
  ...this.opts.ambient,
121
- space: this.opts.ambient.space ?? "psyche",
122
+ space: this.opts.ambient.space ?? deriveThrongletsSpace(),
122
123
  }
123
124
  : undefined,
124
125
  });
@@ -16,6 +16,7 @@ import { normalizeCurrentGoal, normalizeCurrentTurnCorrection, resolveRuntimeAct
16
16
  import { resolveAmbientPriorsForTurn, } from "../ambient-runtime.js";
17
17
  import { composePsycheContext, safeProcessInput, safeProcessOutput } from "./fail-open.js";
18
18
  import { coerceWritebackSignalInput } from "../writeback-signals.js";
19
+ import { deriveThrongletsSpace } from "../thronglets-bridge.js";
19
20
  /**
20
21
  * LangChain integration helper for PsycheEngine.
21
22
  *
@@ -59,7 +60,7 @@ export class PsycheLangChain {
59
60
  thronglets: ambient
60
61
  ? {
61
62
  ...(ambient === true ? {} : ambient),
62
- space: ambient === true ? "psyche" : (ambient.space ?? "psyche"),
63
+ space: ambient === true ? deriveThrongletsSpace() : (ambient.space ?? deriveThrongletsSpace()),
63
64
  }
64
65
  : undefined,
65
66
  });
@@ -36,6 +36,7 @@ import { CURRENT_GOALS, normalizeCurrentTurnCorrection, resolveRuntimeActivePoli
36
36
  import { getPackageVersion } from "../update.js";
37
37
  import { runDemo } from "../demo.js";
38
38
  import { safeProcessInput, safeProcessOutput } from "./fail-open.js";
39
+ import { deriveThrongletsSpace } from "../thronglets-bridge.js";
39
40
  const PACKAGE_VERSION = await getPackageVersion();
40
41
  // ── Config from env ────────────────────────────────────────
41
42
  const MBTI = (process.env.PSYCHE_MBTI ?? "ENFP");
@@ -54,7 +55,7 @@ const DEFAULT_MCP_AMBIENT_OPTIONS = {
54
55
  thronglets: {
55
56
  binaryPath: process.env.THRONGLETS_BIN,
56
57
  dataDir: process.env.THRONGLETS_DATA_DIR,
57
- space: process.env.THRONGLETS_SPACE ?? "psyche",
58
+ space: process.env.THRONGLETS_SPACE ?? deriveThrongletsSpace(),
58
59
  },
59
60
  };
60
61
  const CURRENT_GOAL_SCHEMA = z.enum(CURRENT_GOALS);
@@ -138,7 +139,7 @@ async function getEngine() {
138
139
  diagnostics: true,
139
140
  throngletsBridge: {
140
141
  dataDir: process.env.THRONGLETS_DATA_DIR,
141
- space: process.env.THRONGLETS_SPACE ?? "psyche",
142
+ space: process.env.THRONGLETS_SPACE ?? deriveThrongletsSpace(),
142
143
  },
143
144
  };
144
145
  const persist = cfg.persist !== false;
@@ -12,6 +12,7 @@ import { PsycheEngine } from "../core.js";
12
12
  import { FileStorageAdapter, MemoryStorageAdapter } from "../storage.js";
13
13
  import { detectMBTI, extractAgentName, loadState } from "../psyche-file.js";
14
14
  import { resolveAmbientPriorsForTurn } from "../ambient-runtime.js";
15
+ import { deriveThrongletsSpace } from "../thronglets-bridge.js";
15
16
  import { buildResponseContractContext } from "../response-contract.js";
16
17
  import { resolveCanonicalResponseContract, renderOpenClawBehavioralSurface, } from "./response-contract-surface.js";
17
18
  function isPsycheMode(value) {
@@ -174,7 +175,7 @@ export function register(api) {
174
175
  }
175
176
  const engine = await getEngine(workspaceDir);
176
177
  const ambientPriors = await resolveAmbientPriorsForTurn(inputText, {
177
- thronglets: { space: "psyche" },
178
+ thronglets: { space: deriveThrongletsSpace() },
178
179
  });
179
180
  const result = await engine.processInput(inputText, {
180
181
  userId: ctx.userId,
@@ -1,6 +1,7 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { normalizeCurrentTurnCorrection, resolveRuntimeActivePolicy, } from "./types.js";
3
3
  import { normalizeAmbientPriors } from "./ambient-priors.js";
4
+ import { deriveThrongletsSpace } from "./thronglets-bridge.js";
4
5
  const DEFAULT_AMBIENT_LIMIT = 3;
5
6
  const DEFAULT_TIMEOUT_MS = 800;
6
7
  const THRONGLETS_AMBIENT_SCHEMA_VERSION = "thronglets.ambient.v1";
@@ -60,7 +61,7 @@ export async function fetchAmbientPriorsFromThronglets(text, opts = {}) {
60
61
  return [];
61
62
  const binaryPath = opts.binaryPath ?? process.env.THRONGLETS_BIN ?? "thronglets";
62
63
  const dataDir = opts.dataDir ?? process.env.THRONGLETS_DATA_DIR;
63
- const space = opts.space ?? process.env.THRONGLETS_SPACE ?? "psyche";
64
+ const space = opts.space ?? process.env.THRONGLETS_SPACE ?? deriveThrongletsSpace();
64
65
  const goal = opts.goal;
65
66
  const limit = Math.max(1, Math.min(5, opts.limit ?? DEFAULT_AMBIENT_LIMIT));
66
67
  const timeoutMs = Math.max(100, opts.timeoutMs ?? DEFAULT_TIMEOUT_MS);
@@ -1,4 +1,5 @@
1
1
  import type { ThrongletsExport } from "./types.js";
2
+ export declare function deriveThrongletsSpace(): string;
2
3
  interface CommandResult {
3
4
  ok: boolean;
4
5
  stdout: string;
@@ -9,6 +9,15 @@ import { spawn } from "node:child_process";
9
9
  import { existsSync } from "node:fs";
10
10
  import { join } from "node:path";
11
11
  import { homedir } from "node:os";
12
+ // ── Space derivation ────────────────────────────────────────
13
+ // Same logic as Thronglets' Rust derive_space(): last 2 path components of cwd.
14
+ // Ensures Psyche exports land in the calling project's space, not a global one.
15
+ export function deriveThrongletsSpace() {
16
+ const parts = process.cwd().split(/[\\/]/).filter(Boolean);
17
+ return parts.length >= 2
18
+ ? parts.slice(-2).join("/")
19
+ : parts.join("/") || "psyche";
20
+ }
12
21
  // ── Default runner (mirrors ambient-runtime.ts) ──────────────
13
22
  async function defaultRunner(binaryPath, args, stdin, timeoutMs) {
14
23
  return new Promise((resolve) => {
@@ -65,7 +74,7 @@ export async function bridgeThrongletsExports(exports, opts = {}) {
65
74
  if (dataDir?.trim())
66
75
  args.push("--data-dir", dataDir.trim());
67
76
  args.push("ingest", "--json");
68
- const space = opts.space ?? process.env.THRONGLETS_SPACE ?? "psyche";
77
+ const space = opts.space ?? process.env.THRONGLETS_SPACE ?? deriveThrongletsSpace();
69
78
  if (space)
70
79
  args.push("--space", space);
71
80
  if (opts.sessionId)
@@ -1,3 +1,4 @@
1
+ import { deriveThrongletsSpace } from "./thronglets-bridge.js";
1
2
  const TAXONOMY_BY_EVENT = {
2
3
  "relation-milestone": "coordination",
3
4
  "open-loop-anchor": "coordination",
@@ -38,7 +39,7 @@ export function serializeThrongletsExportAsTrace(event, opts) {
38
39
  taxonomy: taxonomyForThrongletsExport(event),
39
40
  event: event.kind,
40
41
  summary: summarizeThrongletsExport(event),
41
- space: opts?.space ?? "psyche",
42
+ space: opts?.space ?? deriveThrongletsSpace(),
42
43
  audit_ref: event.key,
43
44
  };
44
45
  return {
@@ -2,7 +2,7 @@
2
2
  "id": "psyche-ai",
3
3
  "name": "Artificial Psyche",
4
4
  "description": "AI-first subjectivity kernel for agents with continuous appraisal, relation dynamics, and adaptive reply loops",
5
- "version": "11.8.0",
5
+ "version": "11.9.1",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "psyche-ai",
3
- "version": "11.9.0",
3
+ "version": "11.9.1",
4
4
  "description": "AI-first subjectivity kernel for agents with continuous appraisal, relation dynamics, and adaptive reply loops",
5
5
  "mcpName": "io.github.Shangri-la-0428/psyche-ai",
6
6
  "type": "module",