@applica-software-guru/persona-sdk 0.1.101 → 0.1.103

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.
@@ -9,7 +9,6 @@ export type SynthesizerName = 'gcloud' | 'elevenlabs' | 'gtts' | 'openai';
9
9
 
10
10
  export type TranscriberName = 'gcloud' | 'deepgram' | 'vosk';
11
11
 
12
- export type StmType = 'simple' | 'summary' | 'compact';
13
12
 
14
13
  export type ToolType = 'remote' | 'local';
15
14
 
@@ -43,6 +42,8 @@ export interface ModelConfiguration {
43
42
  reasoningEffort?: ReasoningEffort;
44
43
  /** Maximum number of output tokens to generate. Undefined = provider default. */
45
44
  maxOutputTokens?: number;
45
+ /** Total context window (input) of the model, in tokens. Used by compaction. Undefined = default (128000). */
46
+ contextWindow?: number;
46
47
  /** Override the per-provider default API key (env var) when set. */
47
48
  apiKey?: string;
48
49
  /** Override the per-provider default base URL when set. */
@@ -245,30 +246,15 @@ export interface ToolkitConfiguration {
245
246
  tools?: Tool[];
246
247
  }
247
248
 
248
- export interface StmConfiguration {
249
- type?: StmType;
250
- maxMessages?: number;
251
- includeToolCalls?: boolean;
252
- model?: ModelConfiguration;
253
- maxNumberOfWords?: number;
254
- keepLastNObservations?: number;
255
- maskingThreshold?: number;
256
- summaryThreshold?: number;
257
- maxContextTokens?: number;
258
- }
259
-
260
- export interface ContextManagementConfiguration {
249
+ export interface CompactionConfiguration {
250
+ /** Enable automatic context compaction. Default: true. */
261
251
  enabled?: boolean;
262
- maxContextTokens?: number;
263
- summarizationThreshold?: number;
264
- keepLastNIterations?: number;
265
- keepFirstMessage?: boolean;
266
- maxToolCallsBeforeCompaction?: number;
267
- useLlmCompaction?: boolean;
268
- maxSummaryWords?: number;
269
- truncationEnabled?: boolean;
270
- maxObservationTokens?: number;
271
- compactionModel?: ModelConfiguration;
252
+ /** Headroom kept free below the context window. Default: 16384. */
253
+ reserveTokens?: number;
254
+ /** Token budget of recent conversation never summarized. Default: 20000. */
255
+ keepRecentTokens?: number;
256
+ /** Model used to generate the summary. Defaults to the agent's main model. */
257
+ model?: ModelConfiguration;
272
258
  }
273
259
 
274
260
  export interface Revision {
@@ -307,8 +293,7 @@ export interface Agent {
307
293
  network?: NetworkConfiguration;
308
294
  features?: Feature[];
309
295
  toolkit?: ToolkitConfiguration;
310
- shortTermMemory?: StmConfiguration;
311
- contextManagement?: ContextManagementConfiguration;
296
+ compaction?: CompactionConfiguration;
312
297
  attachmentsPreprocessor?: AttachmentsPreprocessorConfiguration;
313
298
  responseSchema?: Record<string, unknown>;
314
299
  verboseErrors?: boolean;
@@ -339,8 +324,7 @@ export interface AgentCreateRequest {
339
324
  network?: NetworkConfiguration;
340
325
  features?: Feature[];
341
326
  toolkit?: ToolkitConfiguration;
342
- shortTermMemory?: StmConfiguration;
343
- contextManagement?: ContextManagementConfiguration;
327
+ compaction?: CompactionConfiguration;
344
328
  attachmentsPreprocessor?: AttachmentsPreprocessorConfiguration;
345
329
  responseSchema?: Record<string, unknown>;
346
330
  verboseErrors?: boolean;
package/src/index.ts CHANGED
@@ -47,14 +47,12 @@ export type {
47
47
  ToolRemoteConfig,
48
48
  ToolDefinition,
49
49
  ToolkitConfiguration,
50
- StmConfiguration,
51
- StmType,
50
+ CompactionConfiguration,
52
51
  Revision,
53
52
  AgentType,
54
53
  ReasoningEffort,
55
54
  ModelProvider,
56
55
  CollaborationMode,
57
- ContextManagementConfiguration,
58
56
  AttachmentsPreprocessorConfiguration,
59
57
  AttachmentsPreprocessorImageHandling,
60
58
  } from './agents/types';
@@ -95,6 +93,7 @@ export type {
95
93
  } from './knowledges/types';
96
94
  export { WorkflowsApi } from './workflows/workflows-api';
97
95
  export { WorkflowExecutionsApi } from './workflows/workflow-executions-api';
96
+ export { HumanTasksApi } from './workflows/human-tasks-api';
98
97
  export type {
99
98
  Workflow,
100
99
  Node,
@@ -114,6 +113,7 @@ export type {
114
113
  VariableDirection,
115
114
  WorkflowResult,
116
115
  ExecuteRequest,
116
+ HumanTask,
117
117
  AgentValue,
118
118
  ContentItem,
119
119
  ContentItemFile,
@@ -66,6 +66,8 @@ export interface Message {
66
66
  task?: Record<string, unknown>;
67
67
  sender?: string;
68
68
  thought?: boolean;
69
+ /** True when this message is a context-compaction summary (injected by compaction). */
70
+ isCompactionSummary?: boolean;
69
71
  }
70
72
 
71
73
  export interface AgentResponse {
@@ -42,10 +42,6 @@ export class ValuesApi extends HttpApi {
42
42
  return this.httpGet<string[]>('/values/synthesizers/' + synthesizerName + '/voices');
43
43
  }
44
44
 
45
- async getStmTypes(): Promise<string[]> {
46
- return this.httpGet<string[]>('/values/stm-types');
47
- }
48
-
49
45
  async getDocumentExtractors(): Promise<string[]> {
50
46
  return this.httpGet<string[]>('/values/document-extractors');
51
47
  }
@@ -0,0 +1,44 @@
1
+ import { HttpApi } from '../http-api';
2
+ import { Paginated } from '../paginated';
3
+ import { AuthenticationProvider } from '../auth/authentication-provider';
4
+ import { HumanTask } from './types';
5
+
6
+ /**
7
+ * Human-in-the-loop tasks. A task is created when a workflow step
8
+ * suspends waiting for a human (a declared `human` node or an agent
9
+ * escalation); responding to it resumes the run. Lives on the workflows
10
+ * service.
11
+ */
12
+ export class HumanTasksApi extends HttpApi {
13
+ constructor(baseUrl: string, auth: string | AuthenticationProvider) {
14
+ super(baseUrl, auth);
15
+ }
16
+
17
+ /** The project's human-task inbox. */
18
+ async list(
19
+ filters: {
20
+ status?: string;
21
+ assignee?: string;
22
+ workflowId?: string;
23
+ executionId?: string;
24
+ page?: number;
25
+ size?: number;
26
+ } = {},
27
+ ): Promise<Paginated<HumanTask>> {
28
+ const { page, size } = this.normalizePageParams(filters.page, filters.size ?? 50);
29
+ const params: Record<string, unknown> = { page, size };
30
+ if (filters.status ?? 'pending') params.status = filters.status ?? 'pending';
31
+ if (filters.assignee) params.assignee = filters.assignee;
32
+ if (filters.workflowId) params.workflowId = filters.workflowId;
33
+ if (filters.executionId) params.executionId = filters.executionId;
34
+ return this.httpGet<Paginated<HumanTask>>('/human-tasks', params);
35
+ }
36
+
37
+ /** Answer a pending human task, resuming the suspended workflow execution. */
38
+ async respond(humanTaskId: string, response: unknown, respondedBy?: string): Promise<HumanTask> {
39
+ return this.httpPost<HumanTask>('/human-tasks/' + humanTaskId + '/respond', {
40
+ response,
41
+ respondedBy,
42
+ });
43
+ }
44
+ }
@@ -136,6 +136,29 @@ export interface ExecuteRequest {
136
136
  userId?: string;
137
137
  initialData?: Record<string, unknown>;
138
138
  callbackUrl?: string;
139
+ eventsHook?: string;
140
+ }
141
+
142
+ export interface HumanTask {
143
+ id: string;
144
+ projectId?: string;
145
+ workflowId?: string;
146
+ workflowName?: string;
147
+ executionId?: string;
148
+ nodeId?: string;
149
+ stepId?: string;
150
+ origin?: 'node' | 'agent_escalation';
151
+ question?: string;
152
+ payload?: Record<string, unknown>;
153
+ assignee?: string;
154
+ role?: string;
155
+ status: string;
156
+ response?: unknown;
157
+ respondedBy?: string;
158
+ respondedAt?: string;
159
+ createdAt?: string;
160
+ timeoutAt?: string;
161
+ sessionCode?: string;
139
162
  }
140
163
 
141
164
  export interface Workflow {
@@ -25,4 +25,70 @@ export class WorkflowExecutionsApi extends HttpApi {
25
25
  async queue(workflowId: string, request: ExecuteRequest): Promise<Execution> {
26
26
  return this.httpPost<Execution>('/workflows/' + workflowId + '/executions/queue', request);
27
27
  }
28
+
29
+ /** Runs across all workflows in the project (filter by status/workflow/date). */
30
+ async listRuns(filters: {
31
+ status?: string;
32
+ workflowId?: string;
33
+ dateFrom?: string;
34
+ dateTo?: string;
35
+ page?: number;
36
+ size?: number;
37
+ } = {}): Promise<Paginated<Execution>> {
38
+ const { page, size } = this.normalizePageParams(filters.page, filters.size);
39
+ const params: Record<string, unknown> = { page, size };
40
+ if (filters.status) params.status = filters.status;
41
+ if (filters.workflowId) params.workflowId = filters.workflowId;
42
+ if (filters.dateFrom) params.dateFrom = filters.dateFrom;
43
+ if (filters.dateTo) params.dateTo = filters.dateTo;
44
+ return this.httpGet<Paginated<Execution>>('/executions', params);
45
+ }
46
+
47
+ /** Request cancellation of a running/waiting execution (cascades to sub-workflows). */
48
+ async cancel(workflowId: string, executionId: string): Promise<Execution> {
49
+ return this.httpPost<Execution>(
50
+ '/workflows/' + workflowId + '/executions/' + executionId + '/cancel',
51
+ {},
52
+ );
53
+ }
54
+
55
+ /** Re-run an execution from a given node. mode: 'reuse_outputs' | 'fresh'. */
56
+ async rerun(
57
+ workflowId: string,
58
+ executionId: string,
59
+ fromNodeId: string,
60
+ mode: 'reuse_outputs' | 'fresh' = 'reuse_outputs',
61
+ ): Promise<Execution> {
62
+ return this.httpPost<Execution>(
63
+ '/workflows/' + workflowId + '/executions/' + executionId + '/rerun',
64
+ { fromNodeId, mode },
65
+ );
66
+ }
67
+
68
+ /** Execute a single node in isolation with the given inputs (debugging). */
69
+ async dryRunNode(
70
+ workflowId: string,
71
+ nodeId: string,
72
+ inputs: Record<string, unknown> = {},
73
+ ): Promise<Record<string, unknown>> {
74
+ return this.httpPost<Record<string, unknown>>(
75
+ '/workflows/' + workflowId + '/nodes/' + nodeId + '/dry-run',
76
+ { inputs },
77
+ );
78
+ }
79
+
80
+ /** Normalized action trace of an agent step (reasoning, tool calls, messages). */
81
+ async stepTrace(
82
+ workflowId: string,
83
+ executionId: string,
84
+ stepId: string,
85
+ page?: number,
86
+ size?: number,
87
+ ): Promise<Record<string, unknown>> {
88
+ const { page: p, size: s } = this.normalizePageParams(page, size ?? 200);
89
+ return this.httpGet<Record<string, unknown>>(
90
+ '/workflows/' + workflowId + '/executions/' + executionId + '/steps/' + stepId + '/trace',
91
+ { page: p, size: s },
92
+ );
93
+ }
28
94
  }
@@ -4,6 +4,7 @@ import { AuthenticationProvider } from '../auth/authentication-provider';
4
4
  import { Revision } from '../revisions/types';
5
5
  import { Workflow } from './types';
6
6
  import { WorkflowExecutionsApi } from './workflow-executions-api';
7
+ import { HumanTasksApi } from './human-tasks-api';
7
8
 
8
9
  export class WorkflowsApi extends HttpApi {
9
10
  constructor(baseUrl: string, auth: string | AuthenticationProvider) {
@@ -38,6 +39,10 @@ export class WorkflowsApi extends HttpApi {
38
39
  return new WorkflowExecutionsApi(this.getBaseUrl(), this.getAuthProvider());
39
40
  }
40
41
 
42
+ humanTasks(): HumanTasksApi {
43
+ return new HumanTasksApi(this.getBaseUrl(), this.getAuthProvider());
44
+ }
45
+
41
46
  async listRevisions(workflowId: string): Promise<Revision[]> {
42
47
  return this.httpGet<Revision[]>('/workflows/' + workflowId + '/revisions');
43
48
  }