@terminals-tech/sdk 1.0.0-rc.2 → 1.0.0

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.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { JSONSchema7 } from 'json-schema';
2
+ import { Observable } from 'rxjs';
2
3
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
3
4
  import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
4
5
 
@@ -557,6 +558,9 @@ interface CoherenceMetrics$1 {
557
558
  * - Grounding: Connection to factual/contextual reality
558
559
  * - Internal: Self-consistency of reasoning
559
560
  * - Crystallization: Clarity and actionability of output
561
+ *
562
+ * Heuristic primitives are composed from L1 (core/primitives/coherence-heuristics).
563
+ * This module adds weights, configuration, explanations, and audio mapping.
560
564
  */
561
565
 
562
566
  type CoherenceMetrics = CoherenceMetrics$1;
@@ -923,7 +927,7 @@ declare function createDAG<N, E = void>(nodes: DAGNode<N>[], edges: DAGEdge<E>[]
923
927
  * @module sdk-types
924
928
  */
925
929
 
926
- interface NodePolicy$1 {
930
+ interface NodePolicy {
927
931
  fs?: {
928
932
  mode?: "sandboxed" | "full";
929
933
  allowedPaths?: string[];
@@ -933,7 +937,7 @@ interface NodePolicy$1 {
933
937
  allowList?: string[];
934
938
  };
935
939
  }
936
- interface StackPolicies$1 {
940
+ interface StackPolicies {
937
941
  fs?: {
938
942
  mode?: "sandboxed" | "full";
939
943
  allowedPaths?: string[];
@@ -2556,8 +2560,91 @@ declare namespace protocol {
2556
2560
  export { type protocol_AgentBus as AgentBus, type protocol_AgentMessage as AgentMessage, type protocol_AgentMessageType as AgentMessageType, type protocol_DelegationChain as DelegationChain, type protocol_DelegationEdge as DelegationEdge, type protocol_DelegationEdgeInput as DelegationEdgeInput, type protocol_DelegationEndpoint as DelegationEndpoint, protocol_createAgentBus as createAgentBus, protocol_createDelegationChain as createDelegationChain, protocol_createDelegationEdge as createDelegationEdge, protocol_isValidSurfaceId as isValidSurfaceId };
2557
2561
  }
2558
2562
 
2559
- type NodePolicy = NodePolicy$1;
2560
- type StackPolicies = StackPolicies$1;
2563
+ /**
2564
+ * Trigger Type System
2565
+ *
2566
+ * Canonical discriminated-union types for all stack trigger mechanisms.
2567
+ * A trigger defines *when* and *how* a stack run is initiated.
2568
+ *
2569
+ * Usage:
2570
+ * - StackManifestV0.triggerConfig holds the declared trigger for a stack.
2571
+ * - TriggerContext is injected into every run so downstream nodes can inspect
2572
+ * how the execution was started.
2573
+ * - NodeSecretRef lets webhook triggers reference vault-backed HMAC keys
2574
+ * through the provider control plane instead of inline secrets.
2575
+ *
2576
+ * @module machines/core/types/trigger
2577
+ */
2578
+
2579
+ /** Run the stack on a fixed time interval. */
2580
+ interface IntervalTriggerConfig {
2581
+ kind: "interval";
2582
+ /** Seconds between runs. Minimum enforced at 1. */
2583
+ everySeconds: number;
2584
+ }
2585
+ /**
2586
+ * Run the stack on a standard 5-field cron schedule.
2587
+ *
2588
+ * The expression follows the POSIX/Vixie-cron syntax:
2589
+ * `minute hour day-of-month month day-of-week`
2590
+ *
2591
+ * @example "0 9 * * 1-5" // weekdays at 09:00 UTC
2592
+ * @example "* /15 * * * *" // every 15 minutes (non-standard extended form)
2593
+ */
2594
+ interface CronTriggerConfig {
2595
+ kind: "cron";
2596
+ /** Standard 5-field cron expression. */
2597
+ expression: string;
2598
+ /** IANA timezone name (default: "UTC"). */
2599
+ timezone?: string;
2600
+ }
2601
+ /**
2602
+ * Run the stack when an inbound HTTP webhook is received.
2603
+ *
2604
+ * Secret verification:
2605
+ * - Use `secretRef` for production — the key stays server-side.
2606
+ * - Use the inline `secret` field only for dev/test environments.
2607
+ */
2608
+ interface WebhookTriggerConfig {
2609
+ kind: "webhook";
2610
+ /** Relative path segment appended to the stack webhook base URL. */
2611
+ path?: string;
2612
+ /** Accepted HTTP method (default: "POST"). */
2613
+ method?: "GET" | "POST" | "PUT" | "PATCH";
2614
+ /**
2615
+ * Inline HMAC signing secret.
2616
+ * Production deployments should prefer `secretRef` to keep the value
2617
+ * server-side in the Supabase vault.
2618
+ */
2619
+ secret?: string;
2620
+ /** Vault-backed secret reference for the HMAC signing key. */
2621
+ secretRef?: NodeSecretRef;
2622
+ }
2623
+ /**
2624
+ * Run the stack when a matching AXON event is published on the given topic.
2625
+ *
2626
+ * AXON cross-layer events are published via `system.signal.emit.v1` nodes or
2627
+ * directly through the AXON kernel. The filter is applied against the event
2628
+ * payload before dispatching.
2629
+ */
2630
+ interface EventTriggerConfig {
2631
+ kind: "event";
2632
+ /** AXON event topic string (e.g. "brain.index.complete", "user.action.*"). */
2633
+ topic: string;
2634
+ /**
2635
+ * Optional shallow equality filter applied to the event payload.
2636
+ * Only events whose payload contains all key-value pairs in this map
2637
+ * will dispatch the stack run.
2638
+ */
2639
+ filter?: Record<string, unknown>;
2640
+ }
2641
+ /** Run the stack only when explicitly requested via the API or UI. */
2642
+ interface ManualTriggerConfig {
2643
+ kind: "manual";
2644
+ }
2645
+ /** Discriminated union over all trigger kinds. */
2646
+ type TriggerConfig = IntervalTriggerConfig | CronTriggerConfig | WebhookTriggerConfig | EventTriggerConfig | ManualTriggerConfig;
2647
+
2561
2648
  /**
2562
2649
  * Runtime tier for node execution.
2563
2650
  *
@@ -2573,6 +2660,29 @@ type StackPolicies = StackPolicies$1;
2573
2660
  * const tier: RuntimeTier = "worker";
2574
2661
  */
2575
2662
  type RuntimeTier = "worker" | "container-lite" | "webcontainer" | "edge" | "wasm-hvm" | "stack";
2663
+ /**
2664
+ * Secret reference for node execution.
2665
+ *
2666
+ * Links a secret from the vault into node environment.
2667
+ *
2668
+ * @example
2669
+ * const secret: NodeSecretRef = {
2670
+ * name: "api_key",
2671
+ * scope: "stack",
2672
+ * env: "OPENAI_API_KEY",
2673
+ * required: true
2674
+ * };
2675
+ */
2676
+ interface NodeSecretRef {
2677
+ /** Secret identifier in vault */
2678
+ name: string;
2679
+ /** Resolution scope: node-local or stack-wide */
2680
+ scope: "node" | "stack";
2681
+ /** Environment variable name (defaults to name if omitted) */
2682
+ env?: string;
2683
+ /** Whether secret must exist (default: false) */
2684
+ required?: boolean;
2685
+ }
2576
2686
  /**
2577
2687
  * Base manifest fields shared by nodes and stacks.
2578
2688
  *
@@ -2628,6 +2738,24 @@ interface StackRuntimes {
2628
2738
  /** Per-node runtime tier overrides (nodeId -> tiers) */
2629
2739
  overrides?: Record<string, RuntimeTier[]>;
2630
2740
  }
2741
+ /**
2742
+ * Reference from a stack node to a brain connector instance.
2743
+ *
2744
+ * Binds the connector's extracted data chunks into this node's input,
2745
+ * allowing RAG / knowledge-graph results to flow into the execution graph.
2746
+ */
2747
+ interface ConnectorRef {
2748
+ /** ID of the ConnectorInstance in the brain pipeline. */
2749
+ connectorId: string;
2750
+ /** ID of the ConnectorDefinition (catalog entry). */
2751
+ definitionId: string;
2752
+ /**
2753
+ * Optional shallow filter applied to DataChunks from this connector.
2754
+ * Only chunks whose metadata contains all key-value pairs in this map
2755
+ * will be included.
2756
+ */
2757
+ dataChunkFilter?: Record<string, unknown>;
2758
+ }
2631
2759
  /**
2632
2760
  * Node configuration within a stack.
2633
2761
  *
@@ -2655,6 +2783,11 @@ interface StackNodeConfig {
2655
2783
  policies?: NodePolicy;
2656
2784
  /** Secret names from stack.secrets */
2657
2785
  secrets?: string[];
2786
+ /**
2787
+ * Reference to a brain connector whose data chunks feed this node.
2788
+ * The orchestrator resolves this at run-time before invoking the node.
2789
+ */
2790
+ connectorRef?: ConnectorRef;
2658
2791
  }
2659
2792
  /**
2660
2793
  * Directed edge connecting two nodes in the stack DAG.
@@ -2715,6 +2848,14 @@ interface StackManifestV0 extends BaseManifestV0 {
2715
2848
  runtimes?: StackRuntimes;
2716
2849
  /** Provenance layer (L0 or L1) */
2717
2850
  layer?: ManifestLayer;
2851
+ /**
2852
+ * Declared trigger for this stack.
2853
+ *
2854
+ * Defines when and how the stack is automatically started.
2855
+ * The orchestrator and scheduler use this at registration time.
2856
+ * When absent, the stack is manual-only.
2857
+ */
2858
+ triggerConfig?: TriggerConfig;
2718
2859
  }
2719
2860
 
2720
2861
  /**
@@ -3024,6 +3165,171 @@ declare namespace skill {
3024
3165
  export { skill_SKILL_CATEGORIES as SKILL_CATEGORIES, skill_SKILL_RANKS as SKILL_RANKS, skill_SKILL_RUN_STATUSES as SKILL_RUN_STATUSES, skill_SKILL_SIGNAL_CODES as SKILL_SIGNAL_CODES, skill_SKILL_TIERS as SKILL_TIERS, type skill_SkillAgent as SkillAgent, type skill_SkillCapabilities as SkillCapabilities, type skill_SkillCategory as SkillCategory, type skill_SkillEventType as SkillEventType, type skill_SkillHealth as SkillHealth, type skill_SkillManifest as SkillManifest, type skill_SkillMeta as SkillMeta, type skill_SkillRank as SkillRank, type skill_SkillRunStatus as SkillRunStatus, type skill_SkillSignalCode as SkillSignalCode, type skill_SkillTier as SkillTier, skill_ensureSkillsRegistered as ensureSkillsRegistered, skill_getAllSkills as getAllSkills, skill_getSkill as getSkill, skill_getSkillCount as getSkillCount, skill_getSkillsByCategory as getSkillsByCategory, skill_registerSkill as registerSkill };
3025
3166
  }
3026
3167
 
3168
+ /**
3169
+ * Manifold Annihilation API
3170
+ *
3171
+ * Converges an Intent Manifold and a Context Manifold via py2bend compilation
3172
+ * and HVM reduction where available.
3173
+ */
3174
+
3175
+ interface AnnihilationOptions {
3176
+ maxSteps?: number;
3177
+ convergenceThreshold?: number;
3178
+ gravity?: number;
3179
+ }
3180
+ interface ManifoldReductionMetrics {
3181
+ compiled: boolean;
3182
+ reduced: boolean;
3183
+ strategy: string;
3184
+ runtime: "wasm-hvm" | "compile-only";
3185
+ durationMs: number;
3186
+ warnings: string[];
3187
+ errors: string[];
3188
+ logitBias: Record<string, number>;
3189
+ }
3190
+ interface ManifoldSematonPayload {
3191
+ result: string;
3192
+ steps: number;
3193
+ intent: string;
3194
+ contextSnapshot: string;
3195
+ bendCode?: string;
3196
+ reduction: ManifoldReductionMetrics;
3197
+ }
3198
+ declare function annihilate(intent: string, context?: string, options?: AnnihilationOptions): Promise<Sematon<ManifoldSematonPayload>>;
3199
+ declare const manifold: {
3200
+ annihilate: typeof annihilate;
3201
+ };
3202
+
3203
+ type manifold$1_AnnihilationOptions = AnnihilationOptions;
3204
+ type manifold$1_ManifoldReductionMetrics = ManifoldReductionMetrics;
3205
+ type manifold$1_ManifoldSematonPayload = ManifoldSematonPayload;
3206
+ declare const manifold$1_annihilate: typeof annihilate;
3207
+ declare const manifold$1_manifold: typeof manifold;
3208
+ declare namespace manifold$1 {
3209
+ export { type manifold$1_AnnihilationOptions as AnnihilationOptions, type manifold$1_ManifoldReductionMetrics as ManifoldReductionMetrics, type manifold$1_ManifoldSematonPayload as ManifoldSematonPayload, manifold$1_annihilate as annihilate, manifold$1_manifold as manifold };
3210
+ }
3211
+
3212
+ /**
3213
+ * StateMirror - Total Context Encoding
3214
+ *
3215
+ * Continuously encodes the entire application, UI, and cognitive state into a
3216
+ * shared representational manifold. This provides the ObserverKernel with literal
3217
+ * environmental awareness, preventing "blind" execution.
3218
+ */
3219
+
3220
+ interface SystemStateSnapshot {
3221
+ /** The current URL or deep-link active in the browser */
3222
+ activeUrl: string;
3223
+ /** The specific UI component currently focused or under cursor */
3224
+ focusedComponent: string | null;
3225
+ /** The last N intents expressed by the user */
3226
+ recentIntents: string[];
3227
+ /** Latest L1 AudioKernel spectral entropy [0,1] */
3228
+ audioEntropy: number;
3229
+ /** Whether the NanoFold 3D surface is actively rendering */
3230
+ nanoFoldActive: boolean;
3231
+ /** Current System Coherence R [0,1] */
3232
+ coherenceR: number;
3233
+ /** Current active project or workspace ID */
3234
+ activeProject: string | null;
3235
+ }
3236
+ declare class StateMirror {
3237
+ private state$;
3238
+ private bridgeOwnerId;
3239
+ private bridgeOrder;
3240
+ constructor();
3241
+ private initSubscriptions;
3242
+ /** Gets the observable stream of state changes */
3243
+ get stream$(): Observable<SystemStateSnapshot>;
3244
+ /** Gets a synchronous snapshot of the current state */
3245
+ get snapshot(): SystemStateSnapshot;
3246
+ claimBridge(bridgeId: string): void;
3247
+ releaseBridge(bridgeId: string): void;
3248
+ /** Partially updates the mirror state */
3249
+ update(partial: Partial<SystemStateSnapshot>): void;
3250
+ /**
3251
+ * Bridge-scoped update to prevent multiple mounted app shells from racing
3252
+ * against the same singleton mirror.
3253
+ */
3254
+ updateFromBridge(bridgeId: string, partial: Partial<SystemStateSnapshot>): void;
3255
+ /**
3256
+ * Flattens the continuous state into a dense text manifold.
3257
+ * This is passed to the ObserverKernel to ground it in the immediate UI/UX reality.
3258
+ */
3259
+ encodeToManifold(): string;
3260
+ }
3261
+
3262
+ /**
3263
+ * ObserverField & Neurons
3264
+ *
3265
+ * Formalization of the Terminals abstraction:
3266
+ * The MicroLM is not a calculator. It is a continuous ObserverKernel.
3267
+ * Skills are not apps. They are geometric Neurons equipped by the Observer.
3268
+ *
3269
+ * @module sdk/observer
3270
+ */
3271
+
3272
+ /**
3273
+ * A hot-swappable structural template that the Observer equips to resolve intent.
3274
+ */
3275
+ interface Neuron {
3276
+ id: string;
3277
+ kind: "skill" | "isomorphism" | "prompt-sensor" | "py2bend-template";
3278
+ payload: unknown;
3279
+ gravity: number;
3280
+ }
3281
+ interface ObserverConfig {
3282
+ id: string;
3283
+ heartbeatHz?: number;
3284
+ stateMirror?: StateMirror;
3285
+ }
3286
+ /**
3287
+ * ObserverKernel - Continuous Local Witness
3288
+ *
3289
+ * An active, unbroken presence that maintains a heartbeat,
3290
+ * observes the StateMirror, and equips Neurons (skills) dynamically.
3291
+ */
3292
+ declare class ObserverKernel {
3293
+ readonly id: string;
3294
+ readonly heartbeatHz: number;
3295
+ private mirror;
3296
+ private activeNeurons;
3297
+ private coherenceR$;
3298
+ private pulseTimer;
3299
+ constructor(config: ObserverConfig);
3300
+ get coherence(): number;
3301
+ get isRunning(): boolean;
3302
+ /** Starts the continuous heartbeat */
3303
+ start(): void;
3304
+ /** Stops the heartbeat */
3305
+ stop(): void;
3306
+ /** The continuous observation loop */
3307
+ private pulse;
3308
+ /** Equips a new geometric constraint (Neuron) onto the observer */
3309
+ equipNeuron(neuron: Neuron): void;
3310
+ /** Unequips a Neuron */
3311
+ unequipNeuron(neuronId: string): void;
3312
+ /** Replace the active neuron field in one operation. */
3313
+ syncNeurons(neurons: Neuron[]): void;
3314
+ /**
3315
+ * The core execution path:
3316
+ * Flattens the active Neurons + StateMirror context, then drops them into the Annihilator.
3317
+ */
3318
+ resolve(intent: string): Promise<Sematon<any>>;
3319
+ }
3320
+ declare function disposeObserverKernel(id: string): void;
3321
+ declare function getObserverKernel(id: string, config?: Omit<ObserverConfig, "id">): ObserverKernel;
3322
+
3323
+ type observer_Neuron = Neuron;
3324
+ type observer_ObserverConfig = ObserverConfig;
3325
+ type observer_ObserverKernel = ObserverKernel;
3326
+ declare const observer_ObserverKernel: typeof ObserverKernel;
3327
+ declare const observer_disposeObserverKernel: typeof disposeObserverKernel;
3328
+ declare const observer_getObserverKernel: typeof getObserverKernel;
3329
+ declare namespace observer {
3330
+ export { type observer_Neuron as Neuron, type observer_ObserverConfig as ObserverConfig, observer_ObserverKernel as ObserverKernel, observer_disposeObserverKernel as disposeObserverKernel, observer_getObserverKernel as getObserverKernel };
3331
+ }
3332
+
3027
3333
  /**
3028
3334
  * MCP Sampling Support (MCP Specification 2025-11-25)
3029
3335
  *
@@ -3503,6 +3809,6 @@ declare function createAxonBus(): InMemoryAxonBus;
3503
3809
  *
3504
3810
  * Curated package facade for the npm package.
3505
3811
  */
3506
- declare const SDK_VERSION = "1.0.0-rc.1";
3812
+ declare const SDK_VERSION = "1.0.0";
3507
3813
 
3508
- export { type AxonMessage, type AxonMessageBus, brain as Brain, core as Core, InMemoryAxonBus, index as L0, mesh as Mesh, protocol as Protocol, ProtocolBridge, SDK_VERSION, skill as Skill, terminal as Terminal, createAxonBus, createProtocolBridge };
3814
+ export { type AxonMessage, type AxonMessageBus, brain as Brain, core as Core, InMemoryAxonBus, index as L0, manifold$1 as Manifold, mesh as Mesh, observer as Observer, protocol as Protocol, ProtocolBridge, SDK_VERSION, skill as Skill, terminal as Terminal, createAxonBus, createProtocolBridge };