@almadar/agent 2.0.0 → 2.0.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.
Files changed (100) hide show
  1. package/dist/agent/event-budget.d.ts +28 -0
  2. package/dist/agent/experimental/hitl-v2.d.ts +161 -0
  3. package/dist/agent/experimental/hitl-workflow-integration.d.ts +182 -0
  4. package/dist/agent/index.d.ts +14 -0
  5. package/dist/agent/index.js.map +1 -1
  6. package/dist/agent/interrupt-config.d.ts +51 -0
  7. package/dist/agent/session-manager.d.ts +204 -0
  8. package/dist/agent/skill-agent.d.ts +182 -0
  9. package/dist/agent/workflow-middleware.d.ts +63 -0
  10. package/dist/agent/workflow-tool-wrapper.d.ts +87 -0
  11. package/dist/api-types.d.ts +595 -0
  12. package/dist/context/compaction.d.ts +191 -0
  13. package/dist/context-compaction.d.ts +55 -0
  14. package/dist/evals/online-sampling.d.ts +114 -0
  15. package/dist/evals/utils/compact-orbital.d.ts +100 -0
  16. package/dist/event-transformer/event-transformer.d.ts +120 -0
  17. package/dist/event-transformer/index.d.ts +7 -0
  18. package/dist/events.d.ts +85 -0
  19. package/dist/index.d.ts +59 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/memory/MemoryManager.d.ts +243 -0
  22. package/dist/memory/PreferenceLearner.d.ts +59 -0
  23. package/dist/memory/agentic-search.d.ts +116 -0
  24. package/dist/memory/index.d.ts +14 -0
  25. package/dist/memory/memory-orbital.d.ts +66 -0
  26. package/dist/memory/types.d.ts +143 -0
  27. package/dist/metrics.d.ts +77 -0
  28. package/dist/multi-user.d.ts +155 -0
  29. package/dist/observability/index.d.ts +14 -0
  30. package/dist/observability/langsmith-integration.d.ts +203 -0
  31. package/dist/observability.d.ts +196 -0
  32. package/dist/orbitals/archive/sanitize.d.ts +24 -0
  33. package/dist/orbitals/batch/batch-generator.d.ts +41 -0
  34. package/dist/orbitals/batch/concurrency.d.ts +54 -0
  35. package/dist/orbitals/batch/index.d.ts +14 -0
  36. package/dist/orbitals/batch/prompt-assembler.d.ts +92 -0
  37. package/dist/orbitals/batch/types.d.ts +103 -0
  38. package/dist/orbitals/cache/index.d.ts +11 -0
  39. package/dist/orbitals/cache/orbital-fingerprint.d.ts +37 -0
  40. package/dist/orbitals/cache/prompt-assembler.d.ts +65 -0
  41. package/dist/orbitals/cache/structural-templates.d.ts +33 -0
  42. package/dist/orbitals/combiner/index.d.ts +102 -0
  43. package/dist/orbitals/domain-language/index.d.ts +9 -0
  44. package/dist/orbitals/domain-language/prompts/index.d.ts +11 -0
  45. package/dist/orbitals/domain-language/prompts/odl-examples.d.ts +8 -0
  46. package/dist/orbitals/domain-language/prompts/odl-patterns.d.ts +8 -0
  47. package/dist/orbitals/domain-language/prompts/odl-syntax.d.ts +8 -0
  48. package/dist/orbitals/domain-language/prompts/odl-to-schema.d.ts +8 -0
  49. package/dist/orbitals/generation/index.d.ts +10 -0
  50. package/dist/orbitals/generation/orbital-generator.d.ts +120 -0
  51. package/dist/orbitals/shared/constants.d.ts +65 -0
  52. package/dist/orbitals/shared/index.d.ts +11 -0
  53. package/dist/orbitals/shared/types.d.ts +187 -0
  54. package/dist/orbitals/shared/utils.d.ts +97 -0
  55. package/dist/orchestration/complexity-classifier.d.ts +38 -0
  56. package/dist/orchestration/fixing-orchestrator.d.ts +53 -0
  57. package/dist/orchestration/index.d.ts +31 -0
  58. package/dist/orchestration/provider-router.d.ts +45 -0
  59. package/dist/persistence/firestore-checkpointer.d.ts +139 -0
  60. package/dist/persistence/firestore-session-store.d.ts +75 -0
  61. package/dist/persistence/firestore-store.d.ts +86 -0
  62. package/dist/persistence/index.d.ts +10 -0
  63. package/dist/persistence/memory-backend.d.ts +33 -0
  64. package/dist/persistence/types.d.ts +40 -0
  65. package/dist/security/audit-log.d.ts +44 -0
  66. package/dist/state-sync.d.ts +171 -0
  67. package/dist/subagents.d.ts +38 -0
  68. package/dist/tools/combine-schemas.d.ts +154 -0
  69. package/dist/tools/composition.d.ts +119 -0
  70. package/dist/tools/domain-orbital.d.ts +997 -0
  71. package/dist/tools/execute.d.ts +38 -0
  72. package/dist/tools/finish-task.d.ts +56 -0
  73. package/dist/tools/generate-schema.d.ts +53 -0
  74. package/dist/tools/github.d.ts +297 -0
  75. package/dist/tools/index.d.ts +1318 -0
  76. package/dist/tools/orbital-batch-subagent.d.ts +85 -0
  77. package/dist/tools/orbital-subagent.d.ts +454 -0
  78. package/dist/tools/orchestrated-fixing.d.ts +74 -0
  79. package/dist/tools/orchestrated-generation.d.ts +75 -0
  80. package/dist/tools/sandbox-executor.d.ts +31 -0
  81. package/dist/tools/schema-chunking.d.ts +117 -0
  82. package/dist/tools/trait-subagent.d.ts +179 -0
  83. package/dist/tools/validate-schema.d.ts +17 -0
  84. package/dist/types.d.ts +167 -0
  85. package/dist/utils/safety/capability-token.d.ts +50 -0
  86. package/dist/utils/safety/circuit-breaker.d.ts +71 -0
  87. package/dist/utils/safety/index.d.ts +19 -0
  88. package/dist/utils/safety/rate-limiter.d.ts +39 -0
  89. package/dist/utils/safety/threshold-auth.d.ts +70 -0
  90. package/dist/workspace/git-client.d.ts +51 -0
  91. package/dist/workspace/index.d.ts +38 -0
  92. package/dist/workspace/memory-files.d.ts +31 -0
  93. package/dist/workspace/sink-manager.d.ts +26 -0
  94. package/dist/workspace/sinks/firestore-sink.d.ts +41 -0
  95. package/dist/workspace/sinks/git-sink.d.ts +47 -0
  96. package/dist/workspace/sinks/index.d.ts +9 -0
  97. package/dist/workspace/templates.d.ts +32 -0
  98. package/dist/workspace/types.d.ts +86 -0
  99. package/dist/workspace/workspace-manager.d.ts +57 -0
  100. package/package.json +8 -7
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Event Budget Configuration
3
+ *
4
+ * Prevents runaway agent loops with soft/hard event limits per skill.
5
+ */
6
+ /**
7
+ * Event budget limits for different skills.
8
+ * - soft: Warning threshold (agent reminded to finish up)
9
+ * - hard: Maximum events before forced completion
10
+ */
11
+ export declare const EVENT_BUDGETS: Record<string, {
12
+ soft: number;
13
+ hard: number;
14
+ }>;
15
+ /**
16
+ * Get event budget for a skill.
17
+ */
18
+ export declare function getEventBudget(skillName: string): {
19
+ soft: number;
20
+ hard: number;
21
+ };
22
+ /**
23
+ * Generate a budget warning message to inject into the agent.
24
+ */
25
+ export declare function getBudgetWarningMessage(eventCount: number, budget: {
26
+ soft: number;
27
+ hard: number;
28
+ }): string | null;
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Human-in-the-Loop v2 - Phase 2.3
3
+ *
4
+ * Structured interrupts with memory and time-travel debugging.
5
+ * Interrupt types: confirm, edit, select, text
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { MemoryManager } from '../../memory/MemoryManager.js';
10
+ export type InterruptType = 'confirm' | 'edit' | 'select' | 'text';
11
+ export interface InterruptRequest<T = unknown> {
12
+ interruptId: string;
13
+ sessionId: string;
14
+ type: InterruptType;
15
+ title: string;
16
+ description: string;
17
+ context: InterruptContext;
18
+ payload: T;
19
+ timeoutMs?: number;
20
+ createdAt: Date;
21
+ }
22
+ export interface InterruptContext {
23
+ checkpointId: string;
24
+ currentState: string;
25
+ previousActions: string[];
26
+ relevantMemory?: string[];
27
+ }
28
+ export interface InterruptResponse<T = unknown> {
29
+ interruptId: string;
30
+ response: T;
31
+ respondedAt: Date;
32
+ userId?: string;
33
+ }
34
+ export interface ConfirmPayload {
35
+ question: string;
36
+ defaultValue?: boolean;
37
+ severity: 'info' | 'warning' | 'critical';
38
+ }
39
+ export interface EditPayload {
40
+ content: string;
41
+ format: 'json' | 'text' | 'code';
42
+ schema?: Record<string, unknown>;
43
+ validationRules?: string[];
44
+ }
45
+ export interface SelectPayload {
46
+ options: Array<{
47
+ id: string;
48
+ label: string;
49
+ description?: string;
50
+ disabled?: boolean;
51
+ }>;
52
+ multiple?: boolean;
53
+ maxSelections?: number;
54
+ }
55
+ export interface TextPayload {
56
+ placeholder?: string;
57
+ multiline?: boolean;
58
+ maxLength?: number;
59
+ validation?: 'email' | 'url' | 'regex';
60
+ validationRegex?: string;
61
+ }
62
+ export interface HITLv2Options {
63
+ memoryManager?: MemoryManager;
64
+ defaultTimeoutMs?: number;
65
+ onInterrupt?: (request: InterruptRequest) => void;
66
+ onResponse?: (request: InterruptRequest, response: InterruptResponse) => void;
67
+ }
68
+ export declare class HITLv2Manager {
69
+ private options;
70
+ private pendingInterrupts;
71
+ private responses;
72
+ private checkpoints;
73
+ constructor(options?: HITLv2Options);
74
+ /**
75
+ * Create a confirmation interrupt
76
+ */
77
+ confirm(sessionId: string, question: string, options?: {
78
+ severity?: 'info' | 'warning' | 'critical';
79
+ defaultValue?: boolean;
80
+ timeoutMs?: number;
81
+ context?: Partial<InterruptContext>;
82
+ }): Promise<boolean>;
83
+ /**
84
+ * Create an edit interrupt
85
+ */
86
+ edit(sessionId: string, content: string, options?: {
87
+ format?: 'json' | 'text' | 'code';
88
+ title?: string;
89
+ description?: string;
90
+ schema?: Record<string, unknown>;
91
+ timeoutMs?: number;
92
+ context?: Partial<InterruptContext>;
93
+ }): Promise<string>;
94
+ /**
95
+ * Create a selection interrupt
96
+ */
97
+ select<T extends string>(sessionId: string, options: Array<{
98
+ id: T;
99
+ label: string;
100
+ description?: string;
101
+ }>, config?: {
102
+ title?: string;
103
+ description?: string;
104
+ multiple?: boolean;
105
+ timeoutMs?: number;
106
+ context?: Partial<InterruptContext>;
107
+ }): Promise<T | T[]>;
108
+ /**
109
+ * Create a text input interrupt
110
+ */
111
+ text(sessionId: string, options?: {
112
+ title?: string;
113
+ description?: string;
114
+ placeholder?: string;
115
+ multiline?: boolean;
116
+ maxLength?: number;
117
+ timeoutMs?: number;
118
+ context?: Partial<InterruptContext>;
119
+ }): Promise<string>;
120
+ /**
121
+ * Submit a response to an interrupt
122
+ */
123
+ submitResponse<T>(interruptId: string, response: T, userId?: string): Promise<void>;
124
+ /**
125
+ * Cancel an interrupt
126
+ */
127
+ cancelInterrupt(interruptId: string, reason?: string): void;
128
+ /**
129
+ * Save a checkpoint for time-travel
130
+ */
131
+ saveCheckpoint(checkpointId: string, state: unknown): void;
132
+ /**
133
+ * Restore a checkpoint
134
+ */
135
+ restoreCheckpoint<T>(checkpointId: string): T | null;
136
+ /**
137
+ * List available checkpoints
138
+ */
139
+ listCheckpoints(): string[];
140
+ /**
141
+ * Rewind to checkpoint and continue
142
+ */
143
+ rewindToCheckpoint<T>(checkpointId: string, sessionId: string, modifyFn?: (state: T) => T): Promise<T | null>;
144
+ /**
145
+ * Get interrupt statistics
146
+ */
147
+ getStats(): {
148
+ pendingCount: number;
149
+ totalHandled: number;
150
+ checkpointsCount: number;
151
+ averageResponseTimeMs: number;
152
+ };
153
+ /**
154
+ * Get pending interrupts for a session
155
+ */
156
+ getPendingForSession(sessionId: string): InterruptRequest[];
157
+ private createInterrupt;
158
+ private waitForResponse;
159
+ private storeInteraction;
160
+ }
161
+ export declare function createHITLv2Manager(options?: HITLv2Options): HITLv2Manager;
@@ -0,0 +1,182 @@
1
+ /**
2
+ * HITL Workflow Integration - Phase 3.4
3
+ *
4
+ * Human-in-the-Loop with workflow-based conditional branching.
5
+ * Enables complex approval flows with human gates.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import { HITLv2Manager } from './hitl-v2.js';
10
+ import type { MemoryManager } from '../../memory/MemoryManager.js';
11
+ /**
12
+ * Human gate types
13
+ */
14
+ export type HumanGateType = 'approval' | 'edit' | 'select' | 'custom';
15
+ /**
16
+ * Human gate configuration
17
+ */
18
+ export interface HumanGate {
19
+ /** Gate ID */
20
+ id: string;
21
+ /** Gate type */
22
+ type: HumanGateType;
23
+ /** Display title */
24
+ title: string;
25
+ /** Description */
26
+ description: string;
27
+ /** Gate condition - when to show */
28
+ condition?: (context: unknown) => boolean;
29
+ /** Timeout in ms */
30
+ timeoutMs?: number;
31
+ /** Auto-approve if condition met */
32
+ autoApprove?: {
33
+ condition: (context: unknown) => boolean;
34
+ reason: string;
35
+ };
36
+ /** Gate-specific payload */
37
+ payload?: Record<string, unknown>;
38
+ }
39
+ /**
40
+ * Human gate result
41
+ */
42
+ export interface HumanGateResult {
43
+ gateId: string;
44
+ approved: boolean;
45
+ response: unknown;
46
+ respondedAt: number;
47
+ userId?: string;
48
+ autoApproved: boolean;
49
+ }
50
+ /**
51
+ * Workflow branch definition
52
+ */
53
+ export interface WorkflowBranch {
54
+ /** Branch ID */
55
+ id: string;
56
+ /** Branch condition */
57
+ condition: (context: unknown) => boolean;
58
+ /** Steps to execute */
59
+ steps: Array<{
60
+ tool: string;
61
+ input: Record<string, unknown>;
62
+ }>;
63
+ /** Human gate before branch */
64
+ gate?: HumanGate;
65
+ }
66
+ /**
67
+ * HITL workflow definition
68
+ */
69
+ export interface HITLWorkflowDefinition {
70
+ /** Workflow name */
71
+ name: string;
72
+ /** Initial steps (before any gates) */
73
+ initialSteps: Array<{
74
+ tool: string;
75
+ input: Record<string, unknown>;
76
+ }>;
77
+ /** Human gates with conditional branches */
78
+ gates: HumanGate[];
79
+ /** Branches based on gate outcomes */
80
+ branches: WorkflowBranch[];
81
+ /** Fallback if no branches match */
82
+ fallbackBranch?: WorkflowBranch;
83
+ }
84
+ /**
85
+ * HITL workflow result
86
+ */
87
+ export interface HITLWorkflowResult {
88
+ success: boolean;
89
+ output: unknown;
90
+ gatesPassed: HumanGateResult[];
91
+ branchesTaken: string[];
92
+ durationMs: number;
93
+ wasInterrupted: boolean;
94
+ }
95
+ /**
96
+ * HITL workflow options
97
+ */
98
+ export interface HITLWorkflowOptions {
99
+ /** HITL manager */
100
+ hitlManager: HITLv2Manager;
101
+ /** Tool executor */
102
+ toolExecutor: {
103
+ execute(tool: string, input: Record<string, unknown>): Promise<unknown>;
104
+ };
105
+ /** Memory manager */
106
+ memoryManager?: MemoryManager;
107
+ /** Default gate timeout */
108
+ defaultTimeoutMs?: number;
109
+ /** Enable auto-approval learning */
110
+ enableAutoApprove?: boolean;
111
+ }
112
+ export declare class HITLWorkflowEngine {
113
+ private workflowEngine;
114
+ private hitlManager;
115
+ private options;
116
+ private gateHistory;
117
+ constructor(options: HITLWorkflowOptions);
118
+ /**
119
+ * Execute a workflow with human gates
120
+ */
121
+ executeWorkflow(sessionId: string, workflow: HITLWorkflowDefinition, initialContext: Record<string, unknown>): Promise<HITLWorkflowResult>;
122
+ /**
123
+ * Execute initial workflow steps
124
+ */
125
+ private executeInitialSteps;
126
+ /**
127
+ * Execute a human gate
128
+ */
129
+ private executeHumanGate;
130
+ /**
131
+ * Execute approval gate
132
+ */
133
+ private executeApprovalGate;
134
+ /**
135
+ * Execute edit gate
136
+ */
137
+ private executeEditGate;
138
+ /**
139
+ * Execute select gate
140
+ */
141
+ private executeSelectGate;
142
+ /**
143
+ * Execute custom gate
144
+ */
145
+ private executeCustomGate;
146
+ /**
147
+ * Execute branch steps
148
+ */
149
+ private executeBranchSteps;
150
+ /**
151
+ * Wait for interrupt response
152
+ */
153
+ private waitForResponse;
154
+ /**
155
+ * Interpolate input with context
156
+ */
157
+ private interpolateInput;
158
+ /**
159
+ * Get value from path
160
+ */
161
+ private getValueFromPath;
162
+ /**
163
+ * Get gate history for a session
164
+ */
165
+ getGateHistory(sessionId: string): HumanGateResult[];
166
+ /**
167
+ * Clear gate history
168
+ */
169
+ clearGateHistory(sessionId?: string): void;
170
+ }
171
+ /**
172
+ * Schema generation with human review
173
+ */
174
+ export declare function createSchemaGenerationHITLWorkflow(complexity: 'simple' | 'medium' | 'complex'): HITLWorkflowDefinition;
175
+ /**
176
+ * Multi-stage approval workflow
177
+ */
178
+ export declare function createMultiStageApprovalWorkflow(stages: Array<{
179
+ name: string;
180
+ approver: string;
181
+ }>): HITLWorkflowDefinition;
182
+ export declare function createHITLWorkflowEngine(options: HITLWorkflowOptions): HITLWorkflowEngine;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Agent Module
3
+ *
4
+ * Agent factory, session management, event budgets, and interrupt configuration.
5
+ */
6
+ export { createSkillAgent, resumeSkillAgent, Command, } from './skill-agent.js';
7
+ export type { Skill, SkillLoader, SkillRefLoader, SkillAgentOptions, SkillAgentResult, SkillAgent, } from './skill-agent.js';
8
+ export { SessionManager, } from './session-manager.js';
9
+ export type { SessionMetadata, SessionRecord, PersistenceMode, SessionManagerOptions, } from './session-manager.js';
10
+ export { EVENT_BUDGETS, getEventBudget, getBudgetWarningMessage, } from './event-budget.js';
11
+ export { getInterruptConfig, } from './interrupt-config.js';
12
+ export type { SkillMeta, } from './interrupt-config.js';
13
+ export { createWorkflowToolWrapper, createEvalWorkflowWrapper, } from './workflow-tool-wrapper.js';
14
+ export type { WorkflowToolWrapperOptions, ToolTelemetry, WorkflowToolWrapper, } from './workflow-tool-wrapper.js';