@forbocai/core 0.6.0 → 0.6.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/dist/index.mjs CHANGED
@@ -26,8 +26,28 @@ var sdkApi = createApi({
26
26
  return headers;
27
27
  }
28
28
  }),
29
- tagTypes: ["NPC", "Memory", "Cortex", "Ghost", "Soul", "Bridge"],
29
+ tagTypes: ["NPC", "Memory", "Cortex", "Ghost", "Soul", "Bridge", "Rule"],
30
30
  endpoints: (builder) => ({
31
+ // Cortex Endpoints
32
+ getCortexModels: builder.query({
33
+ query: ({ apiUrl, apiKey }) => ({
34
+ url: `${apiUrl}/cortex/models`,
35
+ method: "GET",
36
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
37
+ }),
38
+ providesTags: ["Cortex"],
39
+ transformResponse: (response) => response || []
40
+ }),
41
+ postCortexInit: builder.mutation({
42
+ query: ({ request, apiUrl, apiKey }) => ({
43
+ url: `${apiUrl}/cortex/init`,
44
+ method: "POST",
45
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {},
46
+ body: request
47
+ }),
48
+ invalidatesTags: ["Cortex"],
49
+ transformResponse: (response) => response
50
+ }),
31
51
  // NPC Endpoints
32
52
  postDirective: builder.mutation({
33
53
  query: ({ npcId, request, apiUrl, apiKey }) => ({
@@ -70,88 +90,214 @@ var sdkApi = createApi({
70
90
  };
71
91
  }
72
92
  }),
73
- postSpeak: builder.mutation({
93
+ postMemoryStore: builder.mutation({
74
94
  query: ({ npcId, request, apiUrl, apiKey }) => ({
75
- url: `${apiUrl}/npcs/${npcId}/speak`,
95
+ url: `${apiUrl}/npcs/${npcId}/memory`,
76
96
  method: "POST",
77
97
  headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {},
78
98
  body: request
79
99
  }),
80
- invalidatesTags: (result, error, { npcId }) => [{ type: "NPC", id: npcId }],
100
+ invalidatesTags: (result, error, { npcId }) => [{ type: "Memory", id: npcId }],
81
101
  transformResponse: (response) => response
82
102
  }),
83
- postDialogue: builder.mutation({
103
+ getMemoryList: builder.query({
104
+ query: ({ npcId, apiUrl, apiKey }) => ({
105
+ url: `${apiUrl}/npcs/${npcId}/memory`,
106
+ method: "GET",
107
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
108
+ }),
109
+ providesTags: (result, error, { npcId }) => [{ type: "Memory", id: npcId }],
110
+ transformResponse: (response) => response || []
111
+ }),
112
+ postMemoryRecall: builder.mutation({
84
113
  query: ({ npcId, request, apiUrl, apiKey }) => ({
85
- url: `${apiUrl}/npcs/${npcId}/dialogue`,
114
+ url: `${apiUrl}/npcs/${npcId}/memory/recall`,
86
115
  method: "POST",
87
116
  headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {},
88
117
  body: request
89
118
  }),
90
- invalidatesTags: (result, error, { npcId }) => [{ type: "NPC", id: npcId }],
119
+ invalidatesTags: (result, error, { npcId }) => [{ type: "Memory", id: npcId }],
120
+ transformResponse: (response) => response || []
121
+ }),
122
+ deleteMemoryClear: builder.mutation({
123
+ query: ({ npcId, apiUrl, apiKey }) => ({
124
+ url: `${apiUrl}/npcs/${npcId}/memory/clear`,
125
+ method: "DELETE",
126
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
127
+ }),
128
+ invalidatesTags: (result, error, { npcId }) => [{ type: "Memory", id: npcId }],
91
129
  transformResponse: (response) => response
92
130
  }),
93
131
  // Ghost Endpoints
94
132
  postGhostRun: builder.mutation({
95
- query: ({ request, apiUrl }) => ({ url: `${apiUrl}/ghost/run`, method: "POST", body: request }),
133
+ query: ({ request, apiUrl, apiKey }) => ({
134
+ url: `${apiUrl}/ghost/run`,
135
+ method: "POST",
136
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {},
137
+ body: request
138
+ }),
96
139
  invalidatesTags: ["Ghost"],
97
140
  transformResponse: (response) => response
98
141
  }),
99
142
  getGhostStatus: builder.query({
100
- query: ({ sessionId, apiUrl }) => ({ url: `${apiUrl}/ghost/${sessionId}/status`, method: "GET" }),
143
+ query: ({ sessionId, apiUrl, apiKey }) => ({
144
+ url: `${apiUrl}/ghost/${sessionId}/status`,
145
+ method: "GET",
146
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
147
+ }),
101
148
  providesTags: (result, error, { sessionId }) => [{ type: "Ghost", id: sessionId }],
102
149
  transformResponse: (response) => response
103
150
  }),
104
151
  getGhostResults: builder.query({
105
- query: ({ sessionId, apiUrl }) => ({ url: `${apiUrl}/ghost/${sessionId}/results`, method: "GET" }),
152
+ query: ({ sessionId, apiUrl, apiKey }) => ({
153
+ url: `${apiUrl}/ghost/${sessionId}/results`,
154
+ method: "GET",
155
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
156
+ }),
106
157
  providesTags: (result, error, { sessionId }) => [{ type: "Ghost", id: sessionId }],
107
158
  transformResponse: (response) => response
108
159
  }),
109
160
  postGhostStop: builder.mutation({
110
- query: ({ sessionId, apiUrl }) => ({ url: `${apiUrl}/ghost/${sessionId}/stop`, method: "POST" }),
161
+ query: ({ sessionId, apiUrl, apiKey }) => ({
162
+ url: `${apiUrl}/ghost/${sessionId}/stop`,
163
+ method: "POST",
164
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
165
+ }),
111
166
  invalidatesTags: (result, error, { sessionId }) => [{ type: "Ghost", id: sessionId }],
112
- transformResponse: (response) => ({ stopped: true })
167
+ transformResponse: (response) => ({
168
+ stopped: response?.stopStatus === "stopped",
169
+ stopStatus: response?.stopStatus,
170
+ stopSessionId: response?.stopSessionId
171
+ })
113
172
  }),
114
173
  getGhostHistory: builder.query({
115
- query: ({ limit, apiUrl }) => ({ url: `${apiUrl}/ghost/history?limit=${limit}`, method: "GET" }),
174
+ query: ({ limit, apiUrl, apiKey }) => ({
175
+ url: `${apiUrl}/ghost/history?limit=${limit}`,
176
+ method: "GET",
177
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
178
+ }),
116
179
  providesTags: ["Ghost"],
117
180
  transformResponse: (response) => response
118
181
  }),
119
182
  // Soul Endpoints
120
183
  postSoulExport: builder.mutation({
121
- query: ({ npcId, request, apiUrl }) => ({ url: `${apiUrl}/npcs/${npcId}/soul/export`, method: "POST", body: request }),
184
+ query: ({ npcId, request, apiUrl, apiKey }) => ({
185
+ url: `${apiUrl}/npcs/${npcId}/soul/export`,
186
+ method: "POST",
187
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {},
188
+ body: request
189
+ }),
122
190
  invalidatesTags: ["Soul"],
123
191
  transformResponse: (response) => response
124
192
  }),
125
193
  getSoulImport: builder.query({
126
- query: ({ txId, apiUrl }) => ({ url: `${apiUrl}/souls/${txId}`, method: "GET" }),
194
+ query: ({ txId, apiUrl, apiKey }) => ({
195
+ url: `${apiUrl}/souls/${txId}`,
196
+ method: "GET",
197
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
198
+ }),
127
199
  providesTags: (result, error, { txId }) => [{ type: "Soul", id: txId }],
128
200
  transformResponse: (response) => response
129
201
  }),
130
202
  getSouls: builder.query({
131
- query: ({ limit, apiUrl }) => ({ url: `${apiUrl}/souls?limit=${limit}`, method: "GET" }),
203
+ query: ({ limit, apiUrl, apiKey }) => ({
204
+ url: `${apiUrl}/souls?limit=${limit}`,
205
+ method: "GET",
206
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
207
+ }),
132
208
  providesTags: ["Soul"],
133
209
  transformResponse: (response) => response
134
210
  }),
135
211
  // Bridge Endpoints
136
212
  postBridgeValidate: builder.mutation({
137
- query: ({ request, npcId, apiUrl }) => ({
213
+ query: ({ request, npcId, apiUrl, apiKey }) => ({
138
214
  url: npcId ? `${apiUrl}/bridge/validate/${npcId}` : `${apiUrl}/bridge/validate`,
139
215
  method: "POST",
216
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {},
140
217
  body: request
141
218
  }),
142
219
  invalidatesTags: ["Bridge"],
143
220
  transformResponse: (response) => response.brResult || response
144
221
  }),
145
222
  getBridgeRules: builder.query({
146
- query: ({ apiUrl }) => ({ url: `${apiUrl}/rules`, method: "GET" }),
223
+ query: ({ apiUrl, apiKey }) => ({
224
+ url: `${apiUrl}/bridge/rules`,
225
+ method: "GET",
226
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
227
+ }),
147
228
  providesTags: ["Bridge"],
148
229
  transformResponse: (response) => response
149
230
  }),
150
231
  postBridgePreset: builder.mutation({
151
- query: ({ presetName, apiUrl }) => ({ url: `${apiUrl}/rules/presets/${presetName}`, method: "POST" }),
232
+ query: ({ presetName, apiUrl, apiKey }) => ({
233
+ url: `${apiUrl}/rules/presets/${presetName}`,
234
+ method: "POST",
235
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
236
+ }),
152
237
  invalidatesTags: ["Bridge"],
153
238
  transformResponse: (response) => response
154
239
  }),
240
+ // Rules Endpoints
241
+ getRulesets: builder.query({
242
+ query: ({ apiUrl, apiKey }) => ({
243
+ url: `${apiUrl}/rules`,
244
+ method: "GET",
245
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
246
+ }),
247
+ providesTags: ["Rule"],
248
+ transformResponse: (response) => response || []
249
+ }),
250
+ getRulePresets: builder.query({
251
+ query: ({ apiUrl, apiKey }) => ({
252
+ url: `${apiUrl}/rules/presets`,
253
+ method: "GET",
254
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
255
+ }),
256
+ providesTags: ["Rule"],
257
+ transformResponse: (response) => response || []
258
+ }),
259
+ postRuleRegister: builder.mutation({
260
+ query: ({ request, apiUrl, apiKey }) => ({
261
+ url: `${apiUrl}/rules`,
262
+ method: "POST",
263
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {},
264
+ body: request
265
+ }),
266
+ invalidatesTags: ["Rule"],
267
+ transformResponse: (response) => response
268
+ }),
269
+ deleteRule: builder.mutation({
270
+ query: ({ rulesetId, apiUrl, apiKey }) => ({
271
+ url: `${apiUrl}/rules/${rulesetId}`,
272
+ method: "DELETE",
273
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
274
+ }),
275
+ invalidatesTags: ["Rule"],
276
+ transformResponse: (_response) => ({ deleted: true })
277
+ }),
278
+ // Additional Soul/NPC Endpoints
279
+ postSoulVerify: builder.mutation({
280
+ query: ({ txId, apiUrl, apiKey }) => ({
281
+ url: `${apiUrl}/souls/${txId}/verify`,
282
+ method: "POST",
283
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {}
284
+ }),
285
+ invalidatesTags: ["Soul"],
286
+ transformResponse: (response) => ({
287
+ valid: response.verifyValid ?? response.valid ?? false,
288
+ reason: response.verifyReason ?? response.reason
289
+ })
290
+ }),
291
+ postNpcImport: builder.mutation({
292
+ query: ({ request, apiUrl, apiKey }) => ({
293
+ url: `${apiUrl}/npcs/import`,
294
+ method: "POST",
295
+ headers: apiKey ? { "Authorization": `Bearer ${apiKey}` } : {},
296
+ body: request
297
+ }),
298
+ invalidatesTags: ["NPC"],
299
+ transformResponse: (response) => response
300
+ }),
155
301
  // Cortex Remote Endpoint
156
302
  postCortexComplete: builder.mutation({
157
303
  query: ({ cortexId, prompt, options, apiUrl, apiKey }) => ({
@@ -174,19 +320,22 @@ var sdkApi = createApi({
174
320
  // src/bridgeSlice.ts
175
321
  var initialState = {
176
322
  activePresets: [],
323
+ availableRulesets: [],
324
+ availablePresetIds: [],
177
325
  lastValidation: null,
178
326
  status: "idle",
179
327
  error: null
180
328
  };
181
329
  var validateBridgeThunk = createAsyncThunk(
182
330
  "bridge/validate",
183
- async ({ action, context, npcId, apiUrl }, { dispatch: dispatch2, rejectWithValue }) => {
331
+ async ({ action, context, npcId, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
184
332
  try {
185
333
  const url = apiUrl || "https://api.forboc.ai";
186
334
  const data = await dispatch2(sdkApi.endpoints.postBridgeValidate.initiate({
187
335
  request: { action, context },
188
336
  npcId,
189
- apiUrl: url
337
+ apiUrl: url,
338
+ apiKey
190
339
  })).unwrap();
191
340
  return data;
192
341
  } catch (e) {
@@ -196,10 +345,10 @@ var validateBridgeThunk = createAsyncThunk(
196
345
  );
197
346
  var loadBridgePresetThunk = createAsyncThunk(
198
347
  "bridge/loadPreset",
199
- async ({ presetName, apiUrl }, { dispatch: dispatch2, rejectWithValue }) => {
348
+ async ({ presetName, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
200
349
  try {
201
350
  const url = apiUrl || "https://api.forboc.ai";
202
- return await dispatch2(sdkApi.endpoints.postBridgePreset.initiate({ presetName, apiUrl: url })).unwrap();
351
+ return await dispatch2(sdkApi.endpoints.postBridgePreset.initiate({ presetName, apiUrl: url, apiKey })).unwrap();
203
352
  } catch (e) {
204
353
  return rejectWithValue(e.message || "Failed to load preset");
205
354
  }
@@ -207,15 +356,59 @@ var loadBridgePresetThunk = createAsyncThunk(
207
356
  );
208
357
  var getBridgeRulesThunk = createAsyncThunk(
209
358
  "bridge/rules",
210
- async ({ apiUrl }, { dispatch: dispatch2, rejectWithValue }) => {
359
+ async ({ apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
360
+ try {
361
+ const url = apiUrl || "https://api.forboc.ai";
362
+ return await dispatch2(sdkApi.endpoints.getBridgeRules.initiate({ apiUrl: url, apiKey })).unwrap();
363
+ } catch (e) {
364
+ return rejectWithValue(e.message || "Failed to list bridge rules");
365
+ }
366
+ }
367
+ );
368
+ var listRulesetsThunk = createAsyncThunk(
369
+ "bridge/listRulesets",
370
+ async ({ apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
211
371
  try {
212
372
  const url = apiUrl || "https://api.forboc.ai";
213
- return await dispatch2(sdkApi.endpoints.getBridgeRules.initiate({ apiUrl: url })).unwrap();
373
+ return await dispatch2(sdkApi.endpoints.getRulesets.initiate({ apiUrl: url, apiKey })).unwrap();
214
374
  } catch (e) {
215
375
  return rejectWithValue(e.message || "Failed to list rulesets");
216
376
  }
217
377
  }
218
378
  );
379
+ var listRulePresetsThunk = createAsyncThunk(
380
+ "bridge/listRulePresets",
381
+ async ({ apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
382
+ try {
383
+ const url = apiUrl || "https://api.forboc.ai";
384
+ return await dispatch2(sdkApi.endpoints.getRulePresets.initiate({ apiUrl: url, apiKey })).unwrap();
385
+ } catch (e) {
386
+ return rejectWithValue(e.message || "Failed to list rule presets");
387
+ }
388
+ }
389
+ );
390
+ var registerRulesetThunk = createAsyncThunk(
391
+ "bridge/registerRuleset",
392
+ async ({ ruleset, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
393
+ try {
394
+ const url = apiUrl || "https://api.forboc.ai";
395
+ return await dispatch2(sdkApi.endpoints.postRuleRegister.initiate({ request: ruleset, apiUrl: url, apiKey })).unwrap();
396
+ } catch (e) {
397
+ return rejectWithValue(e.message || "Failed to register ruleset");
398
+ }
399
+ }
400
+ );
401
+ var deleteRulesetThunk = createAsyncThunk(
402
+ "bridge/deleteRuleset",
403
+ async ({ rulesetId, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
404
+ try {
405
+ const url = apiUrl || "https://api.forboc.ai";
406
+ return await dispatch2(sdkApi.endpoints.deleteRule.initiate({ rulesetId, apiUrl: url, apiKey })).unwrap();
407
+ } catch (e) {
408
+ return rejectWithValue(e.message || "Failed to delete ruleset");
409
+ }
410
+ }
411
+ );
219
412
  var bridgeSlice = createSlice({
220
413
  name: "bridge",
221
414
  initialState,
@@ -249,6 +442,10 @@ var bridgeSlice = createSlice({
249
442
  state.status = "error";
250
443
  state.error = action.payload;
251
444
  }).addCase(getBridgeRulesThunk.fulfilled, (state, action) => {
445
+ }).addCase(listRulesetsThunk.fulfilled, (state, action) => {
446
+ state.availableRulesets = action.payload;
447
+ }).addCase(listRulePresetsThunk.fulfilled, (state, action) => {
448
+ state.availablePresetIds = action.payload;
252
449
  });
253
450
  }
254
451
  });
@@ -267,7 +464,7 @@ var initialState2 = {
267
464
  };
268
465
  var remoteExportSoulThunk = createAsyncThunk2(
269
466
  "soul/export",
270
- async ({ npcId: argNpcId, apiUrl, memories = [] }, { getState, dispatch: dispatch2, rejectWithValue }) => {
467
+ async ({ npcId: argNpcId, apiUrl, apiKey, memories = [] }, { getState, dispatch: dispatch2, rejectWithValue }) => {
271
468
  try {
272
469
  const state = getState().npc;
273
470
  const npcId = argNpcId || state.activeNpcId;
@@ -277,7 +474,8 @@ var remoteExportSoulThunk = createAsyncThunk2(
277
474
  const result = await dispatch2(sdkApi.endpoints.postSoulExport.initiate({
278
475
  npcId,
279
476
  request: { npcIdRef: npcId, persona: npc.persona || "NPC", npcState: npc.state },
280
- apiUrl: url
477
+ apiUrl: url,
478
+ apiKey
281
479
  })).unwrap();
282
480
  return {
283
481
  txId: result.txId,
@@ -291,10 +489,10 @@ var remoteExportSoulThunk = createAsyncThunk2(
291
489
  );
292
490
  var importSoulFromArweaveThunk = createAsyncThunk2(
293
491
  "soul/import",
294
- async ({ txId, apiUrl }, { dispatch: dispatch2, rejectWithValue }) => {
492
+ async ({ txId, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
295
493
  try {
296
494
  const url = apiUrl || "https://api.forboc.ai";
297
- const data = await dispatch2(sdkApi.endpoints.getSoulImport.initiate({ txId, apiUrl: url })).unwrap();
495
+ const data = await dispatch2(sdkApi.endpoints.getSoulImport.initiate({ txId, apiUrl: url, apiKey })).unwrap();
298
496
  return data;
299
497
  } catch (e) {
300
498
  return rejectWithValue(e.message || "Soul import failed");
@@ -303,16 +501,42 @@ var importSoulFromArweaveThunk = createAsyncThunk2(
303
501
  );
304
502
  var getSoulListThunk = createAsyncThunk2(
305
503
  "soul/list",
306
- async ({ limit = 50, apiUrl }, { dispatch: dispatch2, rejectWithValue }) => {
504
+ async ({ limit = 50, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
307
505
  try {
308
506
  const url = apiUrl || "https://api.forboc.ai";
309
- const data = await dispatch2(sdkApi.endpoints.getSouls.initiate({ limit, apiUrl: url })).unwrap();
507
+ const data = await dispatch2(sdkApi.endpoints.getSouls.initiate({ limit, apiUrl: url, apiKey })).unwrap();
310
508
  return data.souls || [];
311
509
  } catch (e) {
312
510
  return rejectWithValue(e.message || "Failed to list souls");
313
511
  }
314
512
  }
315
513
  );
514
+ var verifySoulThunk = createAsyncThunk2(
515
+ "soul/verify",
516
+ async ({ txId, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
517
+ try {
518
+ const url = apiUrl || "https://api.forboc.ai";
519
+ return await dispatch2(sdkApi.endpoints.postSoulVerify.initiate({ txId, apiUrl: url, apiKey })).unwrap();
520
+ } catch (e) {
521
+ return rejectWithValue(e.message || "Soul verify failed");
522
+ }
523
+ }
524
+ );
525
+ var importNpcFromSoulThunk = createAsyncThunk2(
526
+ "soul/importNpc",
527
+ async ({ txId, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
528
+ try {
529
+ const url = apiUrl || "https://api.forboc.ai";
530
+ return await dispatch2(sdkApi.endpoints.postNpcImport.initiate({
531
+ request: { txIdRef: txId },
532
+ apiUrl: url,
533
+ apiKey
534
+ })).unwrap();
535
+ } catch (e) {
536
+ return rejectWithValue(e.message || "NPC import from soul failed");
537
+ }
538
+ }
539
+ );
316
540
  var soulSlice = createSlice2({
317
541
  name: "soul",
318
542
  initialState: initialState2,
@@ -370,7 +594,8 @@ var startGhostThunk = createAsyncThunk3(
370
594
  const apiUrl = config.apiUrl || "https://api.forboc.ai";
371
595
  const data = await dispatch2(sdkApi.endpoints.postGhostRun.initiate({
372
596
  request: { testSuite: config.testSuite, duration: config.duration ?? 300 },
373
- apiUrl
597
+ apiUrl,
598
+ apiKey: config.apiKey
374
599
  })).unwrap();
375
600
  return {
376
601
  sessionId: data.sessionId,
@@ -383,13 +608,13 @@ var startGhostThunk = createAsyncThunk3(
383
608
  );
384
609
  var getGhostStatusThunk = createAsyncThunk3(
385
610
  "ghost/status",
386
- async ({ sessionId, apiUrl }, { dispatch: dispatch2, getState, rejectWithValue }) => {
611
+ async ({ sessionId, apiUrl, apiKey }, { dispatch: dispatch2, getState, rejectWithValue }) => {
387
612
  try {
388
613
  const state = getState().ghost;
389
614
  const targetSession = sessionId || state.activeSessionId;
390
615
  if (!targetSession) throw new Error("No active Ghost session");
391
616
  const url = apiUrl || "https://api.forboc.ai";
392
- const data = await dispatch2(sdkApi.endpoints.getGhostStatus.initiate({ sessionId: targetSession, apiUrl: url })).unwrap();
617
+ const data = await dispatch2(sdkApi.endpoints.getGhostStatus.initiate({ sessionId: targetSession, apiUrl: url, apiKey })).unwrap();
393
618
  return {
394
619
  sessionId: data.ghostSessionId,
395
620
  status: data.ghostStatus,
@@ -405,13 +630,13 @@ var getGhostStatusThunk = createAsyncThunk3(
405
630
  );
406
631
  var getGhostResultsThunk = createAsyncThunk3(
407
632
  "ghost/results",
408
- async ({ sessionId, apiUrl }, { dispatch: dispatch2, getState, rejectWithValue }) => {
633
+ async ({ sessionId, apiUrl, apiKey }, { dispatch: dispatch2, getState, rejectWithValue }) => {
409
634
  try {
410
635
  const state = getState().ghost;
411
636
  const targetSession = sessionId || state.activeSessionId;
412
637
  if (!targetSession) throw new Error("No active Ghost session");
413
638
  const url = apiUrl || "https://api.forboc.ai";
414
- const data = await dispatch2(sdkApi.endpoints.getGhostResults.initiate({ sessionId: targetSession, apiUrl: url })).unwrap();
639
+ const data = await dispatch2(sdkApi.endpoints.getGhostResults.initiate({ sessionId: targetSession, apiUrl: url, apiKey })).unwrap();
415
640
  return {
416
641
  sessionId: data.resultsSessionId,
417
642
  totalTests: data.resultsTotalTests,
@@ -436,25 +661,29 @@ var getGhostResultsThunk = createAsyncThunk3(
436
661
  );
437
662
  var stopGhostThunk = createAsyncThunk3(
438
663
  "ghost/stop",
439
- async ({ sessionId, apiUrl }, { dispatch: dispatch2, getState, rejectWithValue }) => {
664
+ async ({ sessionId, apiUrl, apiKey }, { dispatch: dispatch2, getState, rejectWithValue }) => {
440
665
  try {
441
666
  const state = getState().ghost;
442
667
  const targetSession = sessionId || state.activeSessionId;
443
668
  if (!targetSession) throw new Error("No active Ghost session");
444
669
  const url = apiUrl || "https://api.forboc.ai";
445
- await dispatch2(sdkApi.endpoints.postGhostStop.initiate({ sessionId: targetSession, apiUrl: url })).unwrap();
446
- return { stopped: true };
670
+ const data = await dispatch2(sdkApi.endpoints.postGhostStop.initiate({ sessionId: targetSession, apiUrl: url, apiKey })).unwrap();
671
+ return {
672
+ stopped: data.stopped,
673
+ status: data.stopStatus,
674
+ sessionId: data.stopSessionId
675
+ };
447
676
  } catch (e) {
448
- return { stopped: true };
677
+ return rejectWithValue(e.message || "Failed to stop ghost session");
449
678
  }
450
679
  }
451
680
  );
452
681
  var getGhostHistoryThunk = createAsyncThunk3(
453
682
  "ghost/history",
454
- async ({ limit = 10, apiUrl }, { dispatch: dispatch2, rejectWithValue }) => {
683
+ async ({ limit = 10, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
455
684
  try {
456
685
  const url = apiUrl || "https://api.forboc.ai";
457
- const data = await dispatch2(sdkApi.endpoints.getGhostHistory.initiate({ limit, apiUrl: url })).unwrap();
686
+ const data = await dispatch2(sdkApi.endpoints.getGhostHistory.initiate({ limit, apiUrl: url, apiKey })).unwrap();
458
687
  return (data.sessions || []).map((s) => ({
459
688
  sessionId: s.sessionId,
460
689
  testSuite: s.testSuite,
@@ -497,8 +726,14 @@ var ghostSlice = createSlice3({
497
726
  }).addCase(getGhostResultsThunk.fulfilled, (state, action) => {
498
727
  state.results = action.payload;
499
728
  state.status = "completed";
500
- }).addCase(stopGhostThunk.fulfilled, (state) => {
501
- state.status = "failed";
729
+ }).addCase(stopGhostThunk.fulfilled, (state, action) => {
730
+ if (action.payload.stopped) {
731
+ state.status = "failed";
732
+ } else {
733
+ state.error = action.payload.status || "Ghost stop request did not stop a session";
734
+ }
735
+ }).addCase(stopGhostThunk.rejected, (state, action) => {
736
+ state.error = action.payload;
502
737
  }).addCase(getGhostHistoryThunk.fulfilled, (state, action) => {
503
738
  state.history = action.payload;
504
739
  });
@@ -507,11 +742,19 @@ var ghostSlice = createSlice3({
507
742
  var { clearGhostSession } = ghostSlice.actions;
508
743
  var ghostSlice_default = ghostSlice.reducer;
509
744
 
510
- // src/utils.ts
511
- var SDK_VERSION = "0.5.9";
745
+ // src/utils/sdkVersion.ts
746
+ var SDK_VERSION = "0.6.0";
747
+
748
+ // src/utils/generateNPCId.ts
512
749
  var generateNPCId = () => `ag_${Date.now().toString(36)}`;
750
+
751
+ // src/utils/delay.ts
513
752
  var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
753
+
754
+ // src/utils/pipe.ts
514
755
  var pipe = (...fns) => (initialValue) => fns.reduce((acc, fn) => fn(acc), initialValue);
756
+
757
+ // src/utils/memoiseAsync.ts
515
758
  var memoiseAsync = (fn) => {
516
759
  let cached = null;
517
760
  let promise = null;
@@ -525,6 +768,8 @@ var memoiseAsync = (fn) => {
525
768
  return promise;
526
769
  };
527
770
  };
771
+
772
+ // src/utils/memoise.ts
528
773
  var memoise = (fn) => {
529
774
  let cached = null;
530
775
  let initialized = false;
@@ -661,13 +906,34 @@ var initialState4 = {
661
906
  };
662
907
  var initRemoteCortexThunk = createAsyncThunk4(
663
908
  "cortex/initRemote",
664
- async ({ model = "api-integrated" }) => {
665
- return {
666
- id: `remote_${Date.now()}`,
667
- model,
668
- ready: true,
669
- engine: "remote"
670
- };
909
+ async ({ model = "api-integrated", authKey, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
910
+ try {
911
+ const url = apiUrl || "https://api.forboc.ai";
912
+ const data = await dispatch2(sdkApi.endpoints.postCortexInit.initiate({
913
+ request: { requestedModel: model, authKey },
914
+ apiUrl: url,
915
+ apiKey
916
+ })).unwrap();
917
+ return {
918
+ id: data.cortexId,
919
+ model,
920
+ ready: data.state?.toLowerCase() === "ready",
921
+ engine: "remote"
922
+ };
923
+ } catch (e) {
924
+ return rejectWithValue(e.message || "Remote cortex init failed");
925
+ }
926
+ }
927
+ );
928
+ var listCortexModelsThunk = createAsyncThunk4(
929
+ "cortex/listModels",
930
+ async ({ apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
931
+ try {
932
+ const url = apiUrl || "https://api.forboc.ai";
933
+ return await dispatch2(sdkApi.endpoints.getCortexModels.initiate({ apiUrl: url, apiKey })).unwrap();
934
+ } catch (e) {
935
+ return rejectWithValue(e.message || "Failed to list cortex models");
936
+ }
671
937
  }
672
938
  );
673
939
  var completeRemoteThunk = createAsyncThunk4(
@@ -786,6 +1052,93 @@ var selectLastRecalledMemories = (state) => {
786
1052
  };
787
1053
  var memorySlice_default = memorySlice.reducer;
788
1054
 
1055
+ // src/directiveSlice.ts
1056
+ import { createEntityAdapter as createEntityAdapter3, createSlice as createSlice7 } from "@reduxjs/toolkit";
1057
+ var directiveAdapter = createEntityAdapter3();
1058
+ var directiveSlice = createSlice7({
1059
+ name: "directive",
1060
+ initialState: directiveAdapter.getInitialState({
1061
+ activeDirectiveId: ""
1062
+ }),
1063
+ reducers: {
1064
+ directiveRunStarted: (state, action) => {
1065
+ const { id, npcId, observation } = action.payload;
1066
+ directiveAdapter.upsertOne(state, {
1067
+ id,
1068
+ npcId,
1069
+ observation,
1070
+ status: "running",
1071
+ startedAt: Date.now()
1072
+ });
1073
+ state.activeDirectiveId = id;
1074
+ },
1075
+ directiveReceived: (state, action) => {
1076
+ const { id, response } = action.payload;
1077
+ directiveAdapter.updateOne(state, {
1078
+ id,
1079
+ changes: { memoryRecall: response.memoryRecall }
1080
+ });
1081
+ },
1082
+ contextComposed: (state, action) => {
1083
+ const { id, prompt, constraints } = action.payload;
1084
+ directiveAdapter.updateOne(state, {
1085
+ id,
1086
+ changes: { contextPrompt: prompt, contextConstraints: constraints }
1087
+ });
1088
+ },
1089
+ verdictValidated: (state, action) => {
1090
+ const { id, verdict } = action.payload;
1091
+ directiveAdapter.updateOne(state, {
1092
+ id,
1093
+ changes: {
1094
+ status: "completed",
1095
+ completedAt: Date.now(),
1096
+ verdictValid: verdict.valid,
1097
+ verdictDialogue: verdict.dialogue,
1098
+ verdictActionType: verdict.action?.type
1099
+ }
1100
+ });
1101
+ },
1102
+ directiveRunFailed: (state, action) => {
1103
+ const { id, error } = action.payload;
1104
+ directiveAdapter.updateOne(state, {
1105
+ id,
1106
+ changes: {
1107
+ status: "failed",
1108
+ completedAt: Date.now(),
1109
+ error
1110
+ }
1111
+ });
1112
+ },
1113
+ clearDirectivesForNpc: (state, action) => {
1114
+ const npcId = action.payload;
1115
+ const idsToRemove = Object.values(state.entities).filter((item) => Boolean(item)).filter((item) => item.npcId === npcId).map((item) => item.id);
1116
+ directiveAdapter.removeMany(state, idsToRemove);
1117
+ if (idsToRemove.includes(state.activeDirectiveId)) {
1118
+ state.activeDirectiveId = "";
1119
+ }
1120
+ }
1121
+ }
1122
+ });
1123
+ var {
1124
+ directiveRunStarted,
1125
+ directiveReceived,
1126
+ contextComposed,
1127
+ verdictValidated,
1128
+ directiveRunFailed,
1129
+ clearDirectivesForNpc
1130
+ } = directiveSlice.actions;
1131
+ var {
1132
+ selectById: selectDirectiveById,
1133
+ selectAll: selectAllDirectives
1134
+ } = directiveAdapter.getSelectors((state) => state.directive);
1135
+ var selectActiveDirectiveId = (state) => state.directive.activeDirectiveId;
1136
+ var selectActiveDirective = (state) => {
1137
+ const id = selectActiveDirectiveId(state);
1138
+ return state.directive.entities[id];
1139
+ };
1140
+ var directiveSlice_default = directiveSlice.reducer;
1141
+
789
1142
  // src/listeners.ts
790
1143
  import { createListenerMiddleware } from "@reduxjs/toolkit";
791
1144
  var sdkListenerMiddleware = createListenerMiddleware();
@@ -793,8 +1146,14 @@ var startAppListening = sdkListenerMiddleware.startListening.withTypes();
793
1146
  startAppListening({
794
1147
  actionCreator: removeNPC,
795
1148
  effect: async (action, listenerApi) => {
1149
+ const removedNpcId = action.payload;
796
1150
  const state = listenerApi.getState();
797
- if (action.payload === state.npc.activeNpcId) {
1151
+ listenerApi.dispatch(clearDirectivesForNpc(removedNpcId));
1152
+ listenerApi.dispatch(clearBridgeValidation());
1153
+ listenerApi.dispatch(clearGhostSession());
1154
+ listenerApi.dispatch(clearSoulState());
1155
+ listenerApi.dispatch(clearBlock(removedNpcId));
1156
+ if (removedNpcId === state.npc.activeNpcId) {
798
1157
  listenerApi.dispatch(memoryClear());
799
1158
  }
800
1159
  }
@@ -808,6 +1167,7 @@ var createSDKStore = (extraReducers = {}) => {
808
1167
  npc: npcSlice_default,
809
1168
  cortex: cortexSlice_default,
810
1169
  memory: memorySlice_default,
1170
+ directive: directiveSlice_default,
811
1171
  ghost: ghostSlice_default,
812
1172
  soul: soulSlice_default,
813
1173
  bridge: bridgeSlice_default,
@@ -826,101 +1186,85 @@ var dispatch = store.dispatch;
826
1186
  import { createAsyncThunk as createAsyncThunk5 } from "@reduxjs/toolkit";
827
1187
  var processNPC = createAsyncThunk5(
828
1188
  "npc/process",
829
- async ({ npcId: argNpcId, text, context = {}, apiUrl, apiKey, memory, cortex, persona: argPersona }, { getState, dispatch: dispatch2 }) => {
1189
+ async ({ npcId: argNpcId, text, context = {}, apiUrl, apiKey, memory, cortex, persona: argPersona }, { getState, dispatch: dispatch2, rejectWithValue }) => {
830
1190
  const stateNpcId = selectActiveNpcId(getState());
831
1191
  const activeNpc = selectActiveNPC(getState());
832
1192
  const npcId = argNpcId || stateNpcId;
833
1193
  const persona = argPersona || activeNpc?.persona;
834
1194
  const currentState = activeNpc?.state || {};
1195
+ if (!npcId) {
1196
+ return rejectWithValue("No npcId provided and no active NPC selected");
1197
+ }
1198
+ if (!persona) {
1199
+ return rejectWithValue("No persona provided and no active NPC persona available");
1200
+ }
1201
+ if (!cortex) {
1202
+ return rejectWithValue("No local cortex provided. SDK remote cortex fallback is disabled.");
1203
+ }
835
1204
  if (argNpcId && argNpcId !== stateNpcId) {
836
- dispatch2(setNPCInfo({ id: argNpcId, persona: persona || "Default" }));
837
- }
838
- const directiveResult = await dispatch2(
839
- sdkApi.endpoints.postDirective.initiate({ npcId, request: { observation: text, npcState: currentState, context }, apiUrl, apiKey })
840
- ).unwrap();
841
- const recalledMemories = memory && directiveResult.memoryRecall ? await memory.recall(
842
- directiveResult.memoryRecall.query,
843
- directiveResult.memoryRecall.limit,
844
- directiveResult.memoryRecall.threshold
845
- ).then((mems) => mems.map((m) => ({ text: m.text, type: m.type, importance: m.importance }))).catch(() => []) : [];
846
- const contextResult = await dispatch2(
847
- sdkApi.endpoints.postContext.initiate({ npcId, request: { memories: recalledMemories, observation: text, npcState: currentState, persona: persona || "Default" }, apiUrl, apiKey })
848
- ).unwrap();
849
- let generatedText = "";
850
- if (cortex) {
851
- generatedText = await cortex.complete(contextResult.prompt, {
1205
+ dispatch2(setNPCInfo({ id: argNpcId, persona }));
1206
+ }
1207
+ const directiveId = `${npcId}:${Date.now()}`;
1208
+ dispatch2(directiveRunStarted({ id: directiveId, npcId, observation: text }));
1209
+ try {
1210
+ const directiveResult = await dispatch2(
1211
+ sdkApi.endpoints.postDirective.initiate({ npcId, request: { observation: text, npcState: currentState, context }, apiUrl, apiKey })
1212
+ ).unwrap();
1213
+ dispatch2(directiveReceived({ id: directiveId, response: directiveResult }));
1214
+ if (directiveResult.memoryRecall && !memory) {
1215
+ return rejectWithValue("API requested memory recall, but no memory engine is configured");
1216
+ }
1217
+ const recalledMemories = memory && directiveResult.memoryRecall ? (await memory.recall(
1218
+ directiveResult.memoryRecall.query,
1219
+ directiveResult.memoryRecall.limit,
1220
+ directiveResult.memoryRecall.threshold
1221
+ )).map((m) => ({ text: m.text, type: m.type, importance: m.importance })) : [];
1222
+ const contextResult = await dispatch2(
1223
+ sdkApi.endpoints.postContext.initiate({ npcId, request: { memories: recalledMemories, observation: text, npcState: currentState, persona }, apiUrl, apiKey })
1224
+ ).unwrap();
1225
+ dispatch2(contextComposed({ id: directiveId, prompt: contextResult.prompt, constraints: contextResult.constraints }));
1226
+ const generatedText = await cortex.complete(contextResult.prompt, {
852
1227
  maxTokens: contextResult.constraints.maxTokens,
853
1228
  temperature: contextResult.constraints.temperature,
854
1229
  stop: contextResult.constraints.stop
855
1230
  });
856
- } else {
857
- const remoteResult = await dispatch2(sdkApi.endpoints.postCortexComplete.initiate({
858
- cortexId: "remote",
859
- // Or generic
860
- prompt: contextResult.prompt,
861
- options: contextResult.constraints,
862
- apiUrl,
863
- apiKey
864
- })).unwrap();
865
- generatedText = remoteResult.text || "";
866
- }
867
- const verdictResult = await dispatch2(
868
- sdkApi.endpoints.postVerdict.initiate({ npcId, request: { generatedOutput: generatedText, observation: text, npcState: currentState }, apiUrl, apiKey })
869
- ).unwrap();
870
- if (!verdictResult.valid) {
871
- dispatch2(blockAction({ id: npcId, reason: "Validation Failed" }));
872
- return { dialogue: "... [Blocked]", action: { type: "BLOCKED", reason: "Validation Failed" } };
873
- }
874
- if (memory && verdictResult.memoryStore) {
875
- for (const inst of verdictResult.memoryStore) {
876
- await memory.store(inst.text, inst.type, inst.importance).catch((e) => console.warn("Memory store failed:", e));
1231
+ const verdictResult = await dispatch2(
1232
+ sdkApi.endpoints.postVerdict.initiate({ npcId, request: { generatedOutput: generatedText, observation: text, npcState: currentState }, apiUrl, apiKey })
1233
+ ).unwrap();
1234
+ dispatch2(verdictValidated({ id: directiveId, verdict: verdictResult }));
1235
+ if (!verdictResult.valid) {
1236
+ dispatch2(blockAction({ id: npcId, reason: verdictResult.dialogue || "Validation Failed" }));
1237
+ return {
1238
+ dialogue: verdictResult.dialogue,
1239
+ action: verdictResult.action,
1240
+ thought: verdictResult.dialogue
1241
+ };
877
1242
  }
1243
+ if (verdictResult.memoryStore?.length && !memory) {
1244
+ return rejectWithValue("API returned memoryStore instructions, but no memory engine is configured");
1245
+ }
1246
+ if (memory && verdictResult.memoryStore) {
1247
+ for (const inst of verdictResult.memoryStore) {
1248
+ await memory.store(inst.text, inst.type, inst.importance);
1249
+ }
1250
+ }
1251
+ if (verdictResult.stateDelta) {
1252
+ dispatch2(updateNPCState({ id: npcId, delta: verdictResult.stateDelta }));
1253
+ }
1254
+ const action = verdictResult.action;
1255
+ dispatch2(setLastAction({ id: npcId, action }));
1256
+ dispatch2(addToHistory({ id: npcId, role: "user", content: text }));
1257
+ dispatch2(addToHistory({ id: npcId, role: "assistant", content: verdictResult.dialogue }));
1258
+ return {
1259
+ dialogue: verdictResult.dialogue,
1260
+ action,
1261
+ thought: verdictResult.dialogue
1262
+ };
1263
+ } catch (e) {
1264
+ const message = e?.message || e?.data?.message || "Protocol processing failed";
1265
+ dispatch2(directiveRunFailed({ id: directiveId, error: String(message) }));
1266
+ return rejectWithValue(String(message));
878
1267
  }
879
- if (verdictResult.stateDelta) {
880
- dispatch2(updateNPCState({ id: npcId, delta: verdictResult.stateDelta }));
881
- }
882
- const action = verdictResult.action ? { ...verdictResult.action, signature: verdictResult.signature } : void 0;
883
- dispatch2(setLastAction({ id: npcId, action }));
884
- dispatch2(addToHistory({ id: npcId, role: "user", content: text }));
885
- dispatch2(addToHistory({ id: npcId, role: "assistant", content: verdictResult.dialogue }));
886
- return {
887
- dialogue: verdictResult.dialogue,
888
- action,
889
- thought: verdictResult.dialogue
890
- };
891
- }
892
- );
893
- var speakNPC = createAsyncThunk5(
894
- "npc/speak",
895
- async ({ npcId: argNpcId, text, context = {}, apiUrl, apiKey }, { getState, dispatch: dispatch2 }) => {
896
- const stateNpcId = selectActiveNpcId(getState());
897
- const activeNpc = selectActiveNPC(getState());
898
- const npcId = argNpcId || stateNpcId;
899
- const currentState = activeNpc?.state || {};
900
- const data = await dispatch2(sdkApi.endpoints.postSpeak.initiate({
901
- npcId,
902
- request: { speakMessage: text, speakContext: context, speakNPCState: currentState },
903
- apiUrl,
904
- apiKey
905
- })).unwrap();
906
- if (data.speakHistory) {
907
- dispatch2(setHistory({ id: npcId, history: data.speakHistory }));
908
- }
909
- return data.speakReply;
910
- }
911
- );
912
- var dialogueNPC = createAsyncThunk5(
913
- "npc/dialogue",
914
- async ({ npcId: argNpcId, text, context = [], apiUrl, apiKey }, { getState, dispatch: dispatch2 }) => {
915
- const stateNpcId = selectActiveNpcId(getState());
916
- const npcId = argNpcId || stateNpcId;
917
- const data = await dispatch2(sdkApi.endpoints.postDialogue.initiate({
918
- npcId,
919
- request: { diagMessage: text, diagContext: context },
920
- apiUrl,
921
- apiKey
922
- })).unwrap();
923
- return data.diagReply;
924
1268
  }
925
1269
  );
926
1270
  var localExportSoulThunk = createAsyncThunk5(
@@ -930,20 +1274,92 @@ var localExportSoulThunk = createAsyncThunk5(
930
1274
  const npcId = id || state.activeNpcId;
931
1275
  const npc = state.entities[npcId];
932
1276
  if (!npc) throw new Error(`NPC ${npcId} not found`);
933
- const memories = memory ? await memory.export().catch(() => []) : [];
1277
+ const memories = memory ? await memory.export() : [];
934
1278
  return exportToSoul(npcId, "NPC", npc.persona, npc.state, memories);
935
1279
  }
936
1280
  );
1281
+ var checkApiStatusThunk = createAsyncThunk5(
1282
+ "system/checkApiStatus",
1283
+ async ({ apiUrl }, { dispatch: dispatch2, rejectWithValue }) => {
1284
+ try {
1285
+ return await dispatch2(sdkApi.endpoints.getApiStatus.initiate({ apiUrl })).unwrap();
1286
+ } catch (e) {
1287
+ return rejectWithValue(e?.message || "Connection failed");
1288
+ }
1289
+ }
1290
+ );
1291
+ var listMemoryRemoteThunk = createAsyncThunk5(
1292
+ "memory/listRemote",
1293
+ async ({ npcId, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
1294
+ try {
1295
+ const data = await dispatch2(sdkApi.endpoints.getMemoryList.initiate({ npcId, apiUrl, apiKey })).unwrap();
1296
+ return data || [];
1297
+ } catch (e) {
1298
+ return rejectWithValue(e?.message || "Failed to list memories");
1299
+ }
1300
+ }
1301
+ );
1302
+ var recallMemoryRemoteThunk = createAsyncThunk5(
1303
+ "memory/recallRemote",
1304
+ async ({ npcId, query, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
1305
+ try {
1306
+ const data = await dispatch2(
1307
+ sdkApi.endpoints.postMemoryRecall.initiate({
1308
+ npcId,
1309
+ request: { query },
1310
+ apiUrl,
1311
+ apiKey
1312
+ })
1313
+ ).unwrap();
1314
+ return data || [];
1315
+ } catch (e) {
1316
+ return rejectWithValue(e?.message || "Failed to recall memories");
1317
+ }
1318
+ }
1319
+ );
1320
+ var storeMemoryRemoteThunk = createAsyncThunk5(
1321
+ "memory/storeRemote",
1322
+ async ({ npcId, observation, importance = 0.8, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
1323
+ try {
1324
+ return await dispatch2(
1325
+ sdkApi.endpoints.postMemoryStore.initiate({
1326
+ npcId,
1327
+ request: { observation, importance },
1328
+ apiUrl,
1329
+ apiKey
1330
+ })
1331
+ ).unwrap();
1332
+ } catch (e) {
1333
+ return rejectWithValue(e?.message || "Failed to store memory");
1334
+ }
1335
+ }
1336
+ );
1337
+ var clearMemoryRemoteThunk = createAsyncThunk5(
1338
+ "memory/clearRemote",
1339
+ async ({ npcId, apiUrl, apiKey }, { dispatch: dispatch2, rejectWithValue }) => {
1340
+ try {
1341
+ return await dispatch2(
1342
+ sdkApi.endpoints.deleteMemoryClear.initiate({ npcId, apiUrl, apiKey })
1343
+ ).unwrap();
1344
+ } catch (e) {
1345
+ return rejectWithValue(e?.message || "Failed to clear memories");
1346
+ }
1347
+ }
1348
+ );
937
1349
  export {
938
1350
  SDK_VERSION,
939
1351
  addToHistory,
940
1352
  blockAction,
941
1353
  bridgeSlice,
1354
+ checkApiStatusThunk,
942
1355
  clearBlock,
943
1356
  clearBridgeValidation,
1357
+ clearDirectivesForNpc,
944
1358
  clearGhostSession,
1359
+ clearMemoryRemoteThunk,
945
1360
  clearSoulState,
946
1361
  completeRemoteThunk,
1362
+ contextComposed,
947
1363
  cortexInitFailed,
948
1364
  cortexInitStart,
949
1365
  cortexInitSuccess,
@@ -951,7 +1367,11 @@ export {
951
1367
  createInitialState,
952
1368
  createSDKStore,
953
1369
  delay,
954
- dialogueNPC,
1370
+ deleteRulesetThunk,
1371
+ directiveReceived,
1372
+ directiveRunFailed,
1373
+ directiveRunStarted,
1374
+ directiveSlice,
955
1375
  dispatch,
956
1376
  exportToSoul,
957
1377
  generateNPCId,
@@ -961,8 +1381,13 @@ export {
961
1381
  getGhostStatusThunk,
962
1382
  getSoulListThunk,
963
1383
  ghostSlice,
1384
+ importNpcFromSoulThunk,
964
1385
  importSoulFromArweaveThunk,
965
1386
  initRemoteCortexThunk,
1387
+ listCortexModelsThunk,
1388
+ listMemoryRemoteThunk,
1389
+ listRulePresetsThunk,
1390
+ listRulesetsThunk,
966
1391
  loadBridgePresetThunk,
967
1392
  localExportSoulThunk,
968
1393
  memoise,
@@ -978,13 +1403,19 @@ export {
978
1403
  npcSlice,
979
1404
  pipe,
980
1405
  processNPC,
1406
+ recallMemoryRemoteThunk,
1407
+ registerRulesetThunk,
981
1408
  remoteExportSoulThunk,
982
1409
  removeNPC,
983
1410
  sdkApi,
1411
+ selectActiveDirective,
1412
+ selectActiveDirectiveId,
984
1413
  selectActiveNPC,
985
1414
  selectActiveNpcId,
1415
+ selectAllDirectives,
986
1416
  selectAllMemories,
987
1417
  selectAllNPCs,
1418
+ selectDirectiveById,
988
1419
  selectLastRecalledMemories,
989
1420
  selectMemoryById,
990
1421
  selectNPCById,
@@ -998,15 +1429,17 @@ export {
998
1429
  setNPCInfo,
999
1430
  setNPCState,
1000
1431
  soulSlice,
1001
- speakNPC,
1002
1432
  startGhostThunk,
1003
1433
  stopGhostThunk,
1004
1434
  store,
1435
+ storeMemoryRemoteThunk,
1005
1436
  streamFromCortex,
1006
1437
  streamFromCortexWithDelay,
1007
1438
  streamToCallback,
1008
1439
  streamToString,
1009
1440
  updateNPCState,
1010
1441
  updateNPCStateLocally,
1011
- validateBridgeThunk
1442
+ validateBridgeThunk,
1443
+ verdictValidated,
1444
+ verifySoulThunk
1012
1445
  };