glove-foundry 0.6.1 → 0.7.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.
@@ -1,14 +1,15 @@
1
- import { ContentPart, Message, IGloveRunnable, StoreAdapter, GloveFoldArgs, Tool, SubscriberAdapter, RuntimeContextProvider, RuntimeContextOptions, ModelAdapter, DisplayManagerAdapter, HookHandler, DefineSkillArgs, DefineSubAgentArgs, InboxItem } from 'glove-core';
1
+ import * as glove_core from 'glove-core';
2
+ import { Message, IGloveRunnable, StoreAdapter, GloveFoldArgs, Tool, SubscriberAdapter, RuntimeContextProvider, RuntimeContextOptions, ModelAdapter, DisplayManagerAdapter, HookHandler, DefineSkillArgs, DefineSubAgentArgs, InboxItem, ContentPart, AgentEvent } from 'glove-core';
2
3
  import { Schema, Effect } from 'effect';
3
4
  import { z } from 'zod';
4
5
  import { MeshAdapter, AgentIdentity } from 'glove-mesh';
5
6
  import { McpCatalogueEntry, McpAdapter } from 'glove-mcp';
6
7
  import { EntityMemoryAdapter, EpisodicMemoryAdapter, ResourceFsAdapter, ContextAdapter } from 'glove-memory';
7
8
  import { MemoryToolOptions, UseGoalRunnerConfig, UseFormRunnerConfig } from 'glove-memory/tools';
8
- import { EnvSnapshot, EnvFsHandle, WorkingEnvironment, CreateWorkingEnvironmentOptions, MountWorkingEnvironmentConfig, Vfs } from 'glove-working-environment';
9
9
  import { JsSession, MountJsConfig } from 'glove-js';
10
10
  import { LispSession, MountLispConfig } from 'glove-lisp';
11
11
  import { PySession, MountPyConfig } from 'glove-python';
12
+ import { EnvFsHandle, EnvSnapshot, WorkingEnvironment, CreateWorkingEnvironmentOptions, MountWorkingEnvironmentConfig, Vfs } from 'glove-working-environment';
12
13
  import { FactAdapter, FactScope, FactStore, FactInput } from 'glove-facts';
13
14
  import { GoalAdapter, GoalScope, GoalProgram, GoalRunner } from 'glove-memory/goals';
14
15
  import { FormAdapter, FormRunner } from 'glove-memory/forms';
@@ -488,441 +489,366 @@ interface ApplicationConnectionState {
488
489
  }
489
490
  declare function defineConnection<TError = never, TRequirements = never>(options: DefineConnectionOptions<TError, TRequirements>): FoundryApplicationConnection;
490
491
 
491
- type AgentProvisioningPolicy = {
492
- readonly mode: "singleton";
493
- readonly key?: string;
494
- } | {
495
- readonly mode: "per-thread";
496
- } | {
497
- readonly mode: "per-event";
498
- } | {
499
- readonly mode: "existing";
500
- readonly agentIds: ReadonlyArray<string>;
501
- } | {
502
- readonly mode: "custom";
503
- readonly adapter: string;
504
- };
505
- interface PlaybookSubscriptionTarget {
506
- readonly definitionId: string;
507
- readonly provisioning: AgentProvisioningPolicy;
508
- readonly context: Readonly<Record<string, unknown>>;
509
- readonly installations: ReadonlyArray<AgentInstallation>;
510
- }
511
- interface PlaybookSubscription {
492
+ declare const FOUNDRY_SHARED_TOOL_BRAND: unique symbol;
493
+ declare const FOUNDRY_AGENT_APPLICATION_BRAND: unique symbol;
494
+ declare const FOUNDRY_MCP_BRAND: unique symbol;
495
+ declare const FOUNDRY_MEMORY_BRAND: unique symbol;
496
+ type AgentInstallationKind = "tool" | "application" | "mcp";
497
+ type FoundryCapabilityKind = AgentInstallationKind | "memory";
498
+ interface AgentInstallation {
499
+ readonly kind: AgentInstallationKind;
512
500
  readonly id: string;
513
- readonly workspaceId: string;
514
- readonly enabled: boolean;
515
- readonly playbook: AgentPlaybook;
516
- readonly targets: ReadonlyArray<PlaybookSubscriptionTarget>;
517
- readonly createdAt: string;
518
- readonly updatedAt: string;
501
+ /** Durable account selection; code authoring supplies this through an AccountReference. */
502
+ readonly accountId?: string;
503
+ readonly config?: unknown;
519
504
  }
520
- interface PlaybookSubscriptionTargetInput {
521
- readonly agent: FoundryAgentDefinition;
522
- readonly provisioning?: AgentProvisioningPolicy;
523
- readonly context?: Readonly<Record<string, unknown>>;
524
- readonly installations?: ReadonlyArray<AgentInstallation>;
505
+ type FoundryInstallable = FoundrySharedTool<any> | FoundryAgentApplication | FoundryMcp;
506
+ /** Create persisted installation data from a code definition. */
507
+ type DefinitionConfigInput<TDefinition> = TDefinition extends {
508
+ readonly config?: infer TSchema;
509
+ } ? TSchema extends z.ZodType ? z.input<TSchema> : never : never;
510
+ interface InstallationSelection {
511
+ readonly account?: AccountReference;
525
512
  }
526
- interface DefinePlaybookSubscriptionOptions {
527
- /** @deprecated File-routed subscriptions derive identity from their filename. */
528
- readonly id?: string;
529
- readonly workspaceId?: string;
530
- readonly enabled?: boolean;
531
- readonly playbook: AgentPlaybookInput | AgentPlaybook;
532
- readonly targets: ReadonlyArray<PlaybookSubscriptionTargetInput>;
533
- readonly createdAt?: string;
534
- readonly updatedAt?: string;
513
+ declare function install<TDefinition extends FoundryInstallable>(capability: TDefinition, ...configuration: [DefinitionConfigInput<TDefinition>] extends [never] ? [config?: never, selection?: InstallationSelection] : [config: DefinitionConfigInput<TDefinition>, selection?: InstallationSelection]): AgentInstallation;
514
+ declare function installationKey(installation: AgentInstallation): string;
515
+ interface AgentMountBaseContext {
516
+ readonly definitionId: string;
517
+ readonly agentId: string;
518
+ readonly conversationId: string;
519
+ readonly workspaceId: string;
520
+ readonly runId: string;
521
+ readonly input: unknown;
522
+ readonly request: FoundryRequest;
523
+ readonly message: Message;
524
+ readonly messageInput: FoundryMessageInput;
525
+ readonly messageText: string;
526
+ readonly history: ReadonlyArray<Message>;
527
+ readonly messages: ReadonlyArray<Message>;
528
+ readonly glove: IGloveRunnable;
529
+ readonly store: StoreAdapter;
530
+ readonly emit: (event: {
531
+ type: string;
532
+ data?: unknown;
533
+ }) => void;
535
534
  }
536
- interface CustomProvisioningContext {
537
- readonly subscription: PlaybookSubscription;
538
- readonly target: PlaybookSubscriptionTarget;
539
- readonly route: InboundRoute;
540
- readonly eventId: string;
541
- readonly eventName: string;
542
- readonly threadKey: string;
543
- readonly event: unknown;
535
+ interface AgentInstallContext<TConfig = unknown> extends AgentMountBaseContext {
536
+ readonly installation: AgentInstallation;
537
+ readonly config: TConfig;
538
+ readonly accountId?: string;
539
+ readonly withAccountSession?: <A>(operation: string, use: (session: unknown) => Effect.Effect<A, unknown, never>) => Effect.Effect<A, unknown, never>;
544
540
  }
545
- interface CustomProvisionedAgent extends CreateAgentInstanceOptions {
546
- /** Stable uniqueness key; the data adapter enforces it atomically. */
547
- readonly provisioningKey: string;
541
+ interface AgentDefinitionSurfaceContext extends AgentMountBaseContext {
542
+ readonly surface: {
543
+ readonly kind: "memory";
544
+ readonly id: string;
545
+ };
546
+ readonly config: unknown;
548
547
  }
549
- interface FoundryInstanceProvisioner {
550
- readonly identifier: string;
551
- provision(adapter: string, context: CustomProvisioningContext): Effect.Effect<ReadonlyArray<CustomProvisionedAgent>, unknown, never>;
548
+ /** Pure application-definition context. It deliberately exposes no Glove. */
549
+ type AgentApplicationInstallContext<TConfig = unknown> = Omit<AgentInstallContext<TConfig>, "glove" | "store">;
550
+ interface AgentApplicationContribution {
551
+ /** Tools Foundry will mount after the installer returns. */
552
+ readonly tools?: ReadonlyArray<GloveFoldArgs<any>>;
552
553
  }
553
- declare function definePlaybookSubscription(options: DefinePlaybookSubscriptionOptions): PlaybookSubscription;
554
- /** Rehydrate the value-only representation returned by a durable adapter. */
555
- declare function reconstructPlaybookSubscription(subscription: PlaybookSubscription): PlaybookSubscription;
556
-
557
- declare const FOUNDRY_SCHEDULE_BRAND: unique symbol;
558
- type FoundryScheduleTimingInput = {
559
- readonly kind: "at";
560
- readonly at: string;
561
- } | {
562
- readonly kind: "after";
563
- readonly duration: string;
564
- } | {
565
- readonly kind: "every";
566
- readonly interval: string;
554
+ interface ConfiguredCapability<TConfigSchema extends z.ZodType | undefined = z.ZodType | undefined> {
555
+ /** @deprecated File-routed definitions derive identity from their filename. */
556
+ readonly id?: string;
557
+ readonly description: string;
558
+ readonly config?: TConfigSchema;
559
+ }
560
+ type SharedToolOptions<TInput = unknown, TConfigSchema extends z.ZodType | undefined = undefined> = ConfiguredCapability<TConfigSchema> & ({
561
+ readonly tool: GloveFoldArgs<TInput>;
562
+ readonly create?: never;
567
563
  } | {
568
- readonly kind: "cron";
569
- readonly expression: string;
570
- readonly timezone?: string;
564
+ readonly tool?: never;
565
+ readonly create: (context: AgentInstallContext<TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown>) => Effect.Effect<GloveFoldArgs<TInput>, unknown, never>;
566
+ });
567
+ type FoundrySharedTool<TInput = unknown, TConfigSchema extends z.ZodType | undefined = any> = Readonly<SharedToolOptions<TInput, TConfigSchema>> & {
568
+ readonly id: string;
569
+ readonly [FOUNDRY_SHARED_TOOL_BRAND]: true;
571
570
  };
572
- type FoundryScheduleTiming = {
573
- readonly kind: "at";
574
- readonly at: string;
575
- } | {
576
- readonly kind: "every";
577
- readonly intervalMs: number;
578
- } | {
579
- readonly kind: "cron";
580
- readonly expression: string;
581
- readonly timezone: string;
571
+ declare function defineSharedTool<TInput, const TConfigSchema extends z.ZodType | undefined = undefined>(options: SharedToolOptions<TInput, TConfigSchema>): FoundrySharedTool<TInput, TConfigSchema>;
572
+ interface AgentApplicationOptions<TConfigSchema extends z.ZodType | undefined = undefined> extends ConfiguredCapability<TConfigSchema> {
573
+ /** Inbound transmission mechanisms owned by this application. */
574
+ readonly inbound?: ReadonlyArray<AnyFoundryTransmission>;
575
+ /** Outbound transmission mechanisms mounted as tools when installed. */
576
+ readonly outbound?: ReadonlyArray<AnyFoundryTransmission>;
577
+ /** Mixed/bidirectional definitions; prefer inbound/outbound for clarity. */
578
+ readonly transmissions?: ReadonlyArray<AnyFoundryTransmission>;
579
+ /** Purpose-built long-lived provider connections for inbound transmissions. */
580
+ readonly connections?: ReadonlyArray<FoundryApplicationConnection>;
581
+ readonly install?: (context: AgentApplicationInstallContext<TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown>) => Effect.Effect<AgentApplicationContribution | void, unknown, never>;
582
+ }
583
+ type FoundryAgentApplication<TConfigSchema extends z.ZodType | undefined = any> = Readonly<AgentApplicationOptions<TConfigSchema>> & {
584
+ readonly id: string;
585
+ readonly [FOUNDRY_AGENT_APPLICATION_BRAND]: true;
586
+ readonly restrictions?: AppRestrictions;
582
587
  };
583
- interface DefineFoundryScheduleOptions {
584
- /** Stable semantic name within one agent definition. It is not a runtime id. */
585
- readonly name: string;
588
+ declare function defineAgentApplication<const TConfigSchema extends z.ZodType | undefined = undefined>(options: AgentApplicationOptions<TConfigSchema>): FoundryAgentApplication<TConfigSchema>;
589
+ /** Explicit allowlists. Omitted lists grant nothing; nested restrictions intersect. */
590
+ interface AppRestrictions {
591
+ readonly tools?: ReadonlyArray<string>;
592
+ readonly operations?: ReadonlyArray<string>;
593
+ readonly transmissions?: ReadonlyArray<string>;
594
+ }
595
+ /** A restricted view of the same app identity, usable in a catalogue or inheritance. */
596
+ declare function restrictApp<T extends FoundryAgentApplication>(app: T, restrictions: AppRestrictions): T;
597
+ /** Concise authoring name for an agent-local application definition. */
598
+ declare const defineApp: typeof defineAgentApplication;
599
+ type FoundryApp = FoundryAgentApplication;
600
+ interface FoundryMcpOptions<TConfigSchema extends z.ZodType | undefined = undefined> {
601
+ /** @deprecated File-routed definitions derive identity from their filename. */
602
+ readonly id?: string;
586
603
  readonly description?: string;
587
- readonly message: string;
588
- readonly payload?: unknown;
589
- readonly timing: FoundryScheduleTimingInput;
590
- readonly enabled?: boolean;
604
+ readonly config?: TConfigSchema;
605
+ /**
606
+ * Static catalogue metadata or a lazy, instance-configured resolver.
607
+ *
608
+ * The resolver receives decoded installation data but never credentials.
609
+ * Auth remains the responsibility of the agent-owned `mcpAdapter` and is
610
+ * resolved only when glove-mcp opens a connection.
611
+ */
612
+ readonly entry: McpCatalogueEntryWithoutId | ((context: AgentApplicationInstallContext<TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown>) => McpCatalogueEntryWithoutId | Promise<McpCatalogueEntryWithoutId> | Effect.Effect<McpCatalogueEntryWithoutId, unknown, never>);
591
613
  }
592
- type FoundryScheduleDefinition = Readonly<DefineFoundryScheduleOptions> & {
593
- readonly [FOUNDRY_SCHEDULE_BRAND]: true;
614
+ type McpCatalogueEntryWithoutId = McpCatalogueEntry extends infer Entry ? Entry extends unknown ? Omit<Entry, "id"> : never : never;
615
+ type FoundryMcp<TConfigSchema extends z.ZodType | undefined = any> = Readonly<FoundryMcpOptions<TConfigSchema>> & {
616
+ readonly id: string;
617
+ readonly [FOUNDRY_MCP_BRAND]: true;
594
618
  };
595
- declare function defineSchedule(options: DefineFoundryScheduleOptions): FoundryScheduleDefinition;
596
- declare function isFoundrySchedule(value: unknown): value is FoundryScheduleDefinition;
597
-
598
- interface AgentInstance {
619
+ declare function defineMcp<const TConfigSchema extends z.ZodType | undefined = undefined>(options: FoundryMcpOptions<TConfigSchema>): FoundryMcp<TConfigSchema>;
620
+ type MemoryAdapterFactory<A> = (context: AgentDefinitionSurfaceContext) => Effect.Effect<A, unknown, never>;
621
+ interface MemorySurfaceOptions {
622
+ readonly access?: "reader" | "curator";
623
+ readonly tools?: MemoryToolOptions["tools"];
624
+ }
625
+ interface FoundryMemoryProfileOptions<TConfigSchema extends z.ZodType | undefined = undefined> extends ConfiguredCapability<TConfigSchema> {
626
+ readonly entity?: MemorySurfaceOptions & {
627
+ readonly adapter: MemoryAdapterFactory<EntityMemoryAdapter>;
628
+ };
629
+ readonly episodic?: MemorySurfaceOptions & {
630
+ readonly adapter: MemoryAdapterFactory<EpisodicMemoryAdapter>;
631
+ };
632
+ readonly resources?: MemorySurfaceOptions & {
633
+ readonly adapter: MemoryAdapterFactory<ResourceFsAdapter>;
634
+ };
635
+ /** Ambient context remains on the main agent, matching glove-memory. */
636
+ readonly context?: {
637
+ readonly adapter: MemoryAdapterFactory<ContextAdapter>;
638
+ readonly tools?: MemoryToolOptions["tools"];
639
+ };
640
+ /** Escape hatch for subagent-delegated or application-specific composition. */
641
+ readonly mount?: (context: AgentDefinitionSurfaceContext) => Effect.Effect<void, unknown, never>;
642
+ }
643
+ type FoundryMemoryProfile<TConfigSchema extends z.ZodType | undefined = any> = Readonly<FoundryMemoryProfileOptions<TConfigSchema>> & {
599
644
  readonly id: string;
600
- readonly definitionId: string;
601
- readonly workspaceId: string;
602
- /** Stable adapter-enforced key used by lazy subscription provisioning. */
603
- readonly provisioningKey?: string;
604
- readonly context: Readonly<Record<string, unknown>>;
605
- /** Persisted desired state. Definitions only provide the capability catalogue. */
606
- readonly installations: ReadonlyArray<AgentInstallation>;
607
- readonly playbooks: ReadonlyArray<AgentPlaybook>;
608
- readonly createdAt: string;
609
- readonly updatedAt: string;
645
+ readonly [FOUNDRY_MEMORY_BRAND]: true;
646
+ };
647
+ declare function defineMemory<const TConfigSchema extends z.ZodType | undefined = undefined>(options: FoundryMemoryProfileOptions<TConfigSchema>): FoundryMemoryProfile<TConfigSchema>;
648
+ interface FoundryCapabilityRegistry {
649
+ readonly tools: ReadonlyArray<FoundrySharedTool<any>>;
650
+ readonly applications: ReadonlyArray<FoundryAgentApplication>;
651
+ readonly mcp: ReadonlyArray<FoundryMcp>;
652
+ readonly memory: ReadonlyArray<FoundryMemoryProfile>;
610
653
  }
611
- interface Conversation {
654
+ interface FoundryCapabilityManifestEntry {
612
655
  readonly id: string;
613
- readonly agentId: string;
614
- readonly workspaceId: string;
615
- readonly title?: string;
616
- readonly context: Readonly<Record<string, unknown>>;
617
- readonly createdAt: string;
618
- readonly updatedAt: string;
656
+ readonly kind: FoundryCapabilityKind;
657
+ readonly description: string;
658
+ readonly ownership: "instance" | "definition";
659
+ readonly file?: string;
619
660
  }
620
- interface WorkspaceEntry {
621
- readonly workspaceId: string;
622
- readonly key: string;
623
- readonly value: unknown;
624
- readonly updatedAt: string;
661
+ interface FoundryCapabilityManifest {
662
+ readonly tools: ReadonlyArray<FoundryCapabilityManifestEntry>;
663
+ readonly applications: ReadonlyArray<FoundryCapabilityManifestEntry>;
664
+ readonly mcp: ReadonlyArray<FoundryCapabilityManifestEntry>;
665
+ readonly memory: ReadonlyArray<FoundryCapabilityManifestEntry>;
625
666
  }
626
- interface SharedInboxItem {
627
- readonly id: string;
628
- readonly workspaceId: string;
629
- readonly conversationId?: string;
630
- readonly agentId?: string;
631
- readonly topic: string;
632
- readonly payload: unknown;
633
- readonly status: "pending" | "resolved" | "dismissed";
634
- readonly createdAt: string;
635
- readonly updatedAt: string;
667
+ declare const EMPTY_CAPABILITY_REGISTRY: FoundryCapabilityRegistry;
668
+ interface McpAdapterFactory {
669
+ (context: Omit<AgentInstallContext, "installation" | "config"> & {
670
+ readonly installed: ReadonlyArray<FoundryMcp>;
671
+ /** Fully decoded, per-instance MCP selections for this assembly. */
672
+ readonly resolved: ReadonlyArray<FoundryResolvedMcp>;
673
+ }): Effect.Effect<McpAdapter, unknown, never>;
636
674
  }
637
- interface EnvironmentValue {
638
- readonly key: string;
639
- /** Secret values are deliberately never exposed through this primitive. */
640
- readonly value: unknown;
641
- readonly scope: "workspace" | "agent" | "conversation";
642
- readonly workspaceId: string;
643
- readonly agentId?: string;
644
- readonly conversationId?: string;
675
+ interface FoundryResolvedMcp {
676
+ readonly definition: FoundryMcp;
677
+ readonly installation: AgentInstallation;
678
+ readonly config: unknown;
679
+ readonly entry: McpCatalogueEntry;
645
680
  }
646
- interface FoundryTask {
647
- readonly id: string;
648
- readonly workspaceId: string;
649
- readonly agentId?: string;
650
- readonly conversationId?: string;
651
- readonly title: string;
652
- readonly detail?: string;
653
- readonly status: "open" | "in-progress" | "completed" | "cancelled";
654
- readonly createdAt: string;
655
- readonly updatedAt: string;
681
+ declare function isInboxCapableStore(store: StoreAdapter): store is StoreAdapter & Required<Pick<StoreAdapter, "getInboxItems" | "addInboxItem" | "updateInboxItem" | "getResolvedInboxItems">>;
682
+ interface FoundryMemoryReference<TProfile extends FoundryMemoryProfile<any> = FoundryMemoryProfile<any>> {
683
+ readonly profile: TProfile;
684
+ readonly config: DefinitionConfigInput<TProfile>;
656
685
  }
657
- interface InboundDeliveryClaim {
658
- readonly key: string;
659
- readonly status: "pending" | "completed";
660
- readonly runIds: ReadonlyArray<string>;
661
- readonly claimedAt: string;
662
- readonly completedAt?: string;
686
+ type FoundryMemorySelection = FoundryMemoryProfile | FoundryMemoryReference;
687
+ /** Select a configured memory profile with schema-inferred input. */
688
+ declare function configureMemory<TProfile extends FoundryMemoryProfile<any>>(profile: TProfile, config: DefinitionConfigInput<TProfile>): FoundryMemoryReference<TProfile>;
689
+ interface MountAgentDefinitionMemoryOptions {
690
+ readonly registry: FoundryCapabilityRegistry;
691
+ readonly memory: ReadonlyArray<FoundryMemorySelection>;
692
+ readonly context: Omit<AgentDefinitionSurfaceContext, "surface" | "config">;
663
693
  }
664
- /**
665
- * An inbound event handed to one agent and not yet finished with: kept from
666
- * dispatch until the run that handles it settles, so a restart delivers it
667
- * again instead of losing it with the in-memory run queue.
668
- */
669
- interface FoundryPendingInbound {
670
- /** `<routeId>:<eventId>:<agentId>`. */
671
- readonly id: string;
672
- readonly definitionId: string;
673
- /** The request a run for this event starts from. */
674
- readonly request: FoundryRequest;
675
- /** The run handling it now; absent while the event waits for its conversation. */
676
- readonly runId?: string;
677
- readonly createdAt: string;
694
+ /** Mount definition-owned memory surfaces for one assembled run. */
695
+ declare function mountAgentDefinitionMemory(options: MountAgentDefinitionMemoryOptions): Effect.Effect<void, unknown, never>;
696
+ interface InstallRegistryOptions {
697
+ /** Revalidate borrowed installation authority before each tool/session operation. */
698
+ readonly authorizeInstallation?: (installation: AgentInstallation) => Effect.Effect<void, unknown, never>;
699
+ readonly registry: FoundryCapabilityRegistry;
700
+ readonly installations: ReadonlyArray<AgentInstallation>;
701
+ readonly context: Omit<AgentInstallContext, "installation" | "config">;
702
+ readonly mcpAdapter?: McpAdapterFactory;
703
+ readonly accountSessions?: FoundryAccountSessionAdapter;
678
704
  }
679
- interface FoundryWorkingEnvironmentSnapshotOwner {
680
- readonly scope: "agent" | "conversation";
705
+ interface FoundryAccountSessionAdapter {
706
+ readonly identifier: string;
707
+ withSession<A>(request: {
708
+ readonly accountId: string;
709
+ readonly operation: string;
710
+ readonly agentId: string;
711
+ readonly conversationId: string;
712
+ readonly workspaceId: string;
713
+ }, use: (session: unknown) => Effect.Effect<A, unknown, never>): Effect.Effect<A, unknown, never>;
714
+ }
715
+ /** Install only explicitly selected capabilities onto a running Glove. */
716
+ declare function installRegistry(options: InstallRegistryOptions): Effect.Effect<ReadonlyArray<AgentInstallation>, unknown, never>;
717
+ declare function isFoundryCapability(value: unknown): boolean;
718
+
719
+ declare const FOUNDRY_WORKING_ENVIRONMENT_BRAND: unique symbol;
720
+ declare const FOUNDRY_REPL_BRAND: unique symbol;
721
+ type FoundryVfs = Vfs;
722
+ type FoundryVfsHandle = EnvFsHandle;
723
+ interface FoundryWorkingEnvironmentPersistenceContext {
681
724
  readonly definitionId: string;
682
725
  readonly agentId: string;
683
726
  readonly conversationId: string;
684
727
  readonly workspaceId: string;
728
+ readonly runId: string;
729
+ readonly data: FoundryDataAdapter;
730
+ readonly signal: AbortSignal;
685
731
  }
686
732
  /**
687
- * Adapter-backed runtime data created by Foundry's scheduling and sleep tools.
688
- * This is reconstructed state, never a file-authored definition primitive.
733
+ * Storage is deliberately adapter-owned. Foundry never chooses a database,
734
+ * object store, locking policy, or credential lifecycle for an environment.
689
735
  */
690
- interface FoundryActivationRecord {
691
- readonly id: string;
692
- readonly kind: "scheduled" | "sleep";
693
- readonly definitionId: string;
694
- readonly agentId: string;
695
- readonly conversationId: string;
696
- readonly workspaceId: string;
697
- readonly message: string;
698
- readonly payload?: unknown;
699
- readonly timing: FoundryScheduleTiming;
700
- readonly origin: "agent-definition" | "agent-tool";
701
- readonly scheduleName?: string;
702
- /** Hash of the last reconciled definition value; runtime edits remain overrides. */
703
- readonly definitionRevision?: string;
704
- readonly status: "pending" | "active" | "paused" | "completed" | "cancelled";
705
- readonly createdByRunId: string;
706
- readonly lastRunId?: string;
707
- readonly createdAt: string;
708
- readonly updatedAt: string;
709
- }
710
- interface FoundryDataAdapter {
736
+ interface FoundryWorkingEnvironmentPersistenceAdapter {
711
737
  readonly identifier: string;
712
- getAgent(id: string): Effect.Effect<AgentInstance | null, unknown, never>;
713
- putAgent(agent: AgentInstance): Effect.Effect<void, unknown, never>;
714
- listAgents(definitionId?: string): Effect.Effect<ReadonlyArray<AgentInstance>, unknown, never>;
715
- provisionAgent(input: ProvisionAgentOptions): Effect.Effect<AgentInstance, unknown, never>;
716
- getPlaybookSubscription(id: string): Effect.Effect<PlaybookSubscription | null, unknown, never>;
717
- putPlaybookSubscription(subscription: PlaybookSubscription): Effect.Effect<void, unknown, never>;
718
- deletePlaybookSubscription(id: string): Effect.Effect<boolean, unknown, never>;
719
- listPlaybookSubscriptions(workspaceId?: string): Effect.Effect<ReadonlyArray<PlaybookSubscription>, unknown, never>;
720
- getInboundDelivery(key: string): Effect.Effect<InboundDeliveryClaim | null, unknown, never>;
721
- claimInboundDelivery(key: string): Effect.Effect<boolean, unknown, never>;
722
- completeInboundDelivery(key: string, runIds: ReadonlyArray<string>): Effect.Effect<void, unknown, never>;
723
- releaseInboundDelivery(key: string): Effect.Effect<void, unknown, never>;
738
+ readonly load: (context: FoundryWorkingEnvironmentPersistenceContext) => Resolvable<EnvSnapshot | null>;
739
+ readonly save: (snapshot: EnvSnapshot, context: FoundryWorkingEnvironmentPersistenceContext) => Resolvable<void>;
740
+ }
741
+ interface FoundryWorkingEnvironmentCreateContext {
742
+ readonly assembly: AgentAssemblyContext<FoundryRequest>;
743
+ readonly snapshot: EnvSnapshot | null;
744
+ }
745
+ interface DefineFoundryWorkingEnvironmentOptions {
724
746
  /**
725
- * Pending inbound events (optional). With these, an inbound event survives
726
- * a restart until the run that handles it finishes; without them, an event
727
- * whose run was still queued or running when the process stopped is lost.
747
+ * Build the native Glove environment. Use this when creation itself needs
748
+ * custom logic. The loaded snapshot is provided but never applied implicitly.
728
749
  */
729
- putPendingInbound?(record: FoundryPendingInbound): Effect.Effect<void, unknown, never>;
730
- deletePendingInbound?(id: string): Effect.Effect<void, unknown, never>;
731
- listPendingInbound?(): Effect.Effect<ReadonlyArray<FoundryPendingInbound>, unknown, never>;
732
- getActivation(id: string): Effect.Effect<FoundryActivationRecord | null, unknown, never>;
733
- putActivation(activation: FoundryActivationRecord): Effect.Effect<void, unknown, never>;
734
- listActivations(workspaceId?: string): Effect.Effect<ReadonlyArray<FoundryActivationRecord>, unknown, never>;
735
- getConversation(id: string): Effect.Effect<Conversation | null, unknown, never>;
736
- putConversation(conversation: Conversation): Effect.Effect<void, unknown, never>;
737
- listConversations(agentId: string): Effect.Effect<ReadonlyArray<Conversation>, unknown, never>;
738
- getWorkspaceEntry(workspaceId: string, key: string): Effect.Effect<WorkspaceEntry | null, unknown, never>;
739
- putWorkspaceEntry(entry: WorkspaceEntry): Effect.Effect<void, unknown, never>;
740
- /** Atomic optimistic update. null requires absence; updates must advance updatedAt. */
741
- compareAndSetWorkspaceEntry?(entry: WorkspaceEntry, expectedUpdatedAt: string | null): Effect.Effect<boolean, unknown, never>;
742
- listWorkspaceEntries(workspaceId: string): Effect.Effect<ReadonlyArray<WorkspaceEntry>, unknown, never>;
743
- /** Private VFS persistence; snapshots are never exposed as workspace entries. */
744
- getWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner): Effect.Effect<EnvSnapshot | null, unknown, never>;
745
- putWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner, snapshot: EnvSnapshot): Effect.Effect<void, unknown, never>;
746
- putInboxItem(item: SharedInboxItem): Effect.Effect<void, unknown, never>;
747
- listInboxItems(workspaceId: string): Effect.Effect<ReadonlyArray<SharedInboxItem>, unknown, never>;
748
- putTask(task: FoundryTask): Effect.Effect<void, unknown, never>;
749
- listTasks(workspaceId: string): Effect.Effect<ReadonlyArray<FoundryTask>, unknown, never>;
750
- listEnvironment(scope: {
751
- readonly workspaceId: string;
752
- readonly agentId?: string;
753
- readonly conversationId?: string;
754
- }): Effect.Effect<ReadonlyArray<EnvironmentValue>, unknown, never>;
755
- }
756
- /** The exact request shape accepted by `Glove.processRequest`. */
757
- type FoundryMessageInput = string | ReadonlyArray<ContentPart>;
758
- interface FoundryRequest {
759
- readonly agentId: string;
760
- readonly conversationId: string;
761
- readonly workspaceId: string;
762
- readonly message: FoundryMessageInput;
763
- readonly payload?: unknown;
764
- readonly context?: Readonly<Record<string, unknown>>;
765
- readonly source?: {
766
- readonly kind: "direct" | "transmission" | "activation" | "spawn" | "background" | "delegation";
767
- readonly id?: string;
768
- readonly provider?: string;
769
- readonly eventId?: string;
770
- readonly threadKey?: string;
771
- };
750
+ readonly create?: (context: FoundryWorkingEnvironmentCreateContext) => Resolvable<WorkingEnvironment>;
751
+ /**
752
+ * Native environment options. When persistence returns a snapshot and no
753
+ * filesystem is supplied, Foundry restores that snapshot automatically.
754
+ */
755
+ readonly options?: CreateWorkingEnvironmentOptions | ((context: FoundryWorkingEnvironmentCreateContext) => Resolvable<CreateWorkingEnvironmentOptions>);
756
+ readonly persistence?: FoundryWorkingEnvironmentPersistenceAdapter;
757
+ /** Native mount behavior: prompt priming and optional tool prefix. */
758
+ readonly mount?: Omit<MountWorkingEnvironmentConfig, "env">;
759
+ /** Close worker/adaptor resources after the run. Default true. */
760
+ readonly close?: boolean;
772
761
  }
762
+ type FoundryWorkingEnvironmentDefinition = Readonly<DefineFoundryWorkingEnvironmentOptions> & {
763
+ readonly [FOUNDRY_WORKING_ENVIRONMENT_BRAND]: true;
764
+ };
765
+ declare function defineWorkingEnvironment(options?: DefineFoundryWorkingEnvironmentOptions): FoundryWorkingEnvironmentDefinition;
773
766
  /**
774
- * Normalize Foundry's wire input into the native user `Message` seen by the
775
- * Glove loop. Lazy assembly happens before hooks run, so this intentionally
776
- * represents the unmodified inbound turn.
767
+ * Convenience persistence over the configured FoundryDataAdapter's private
768
+ * snapshot seam. VFS contents never become public workspace entries.
777
769
  */
778
- declare function toGloveMessage(input: FoundryMessageInput): Message;
779
- /** Clone readonly request parts for Glove's mutable public input signature. */
780
- declare function toGloveRequestInput(input: FoundryMessageInput): string | ContentPart[];
781
- interface FoundryResult {
782
- readonly status: "completed" | "suspended";
783
- readonly value: unknown;
784
- readonly agentId: string;
785
- readonly conversationId: string;
786
- readonly workspaceId: string;
787
- readonly suspension?: FoundrySuspension;
770
+ declare function foundryDataEnvironmentPersistence(options?: {
771
+ readonly scope?: "agent" | "conversation";
772
+ }): FoundryWorkingEnvironmentPersistenceAdapter;
773
+ interface FoundryReplBase {
774
+ readonly [FOUNDRY_REPL_BRAND]: true;
775
+ /**
776
+ * Project an explicit set of the fully assembled agent's tools into the
777
+ * sandbox as ordinary functions. Selection happens after applications,
778
+ * installed capabilities, memory, mesh, calls, and `configure` have mounted.
779
+ *
780
+ * Returning the actual tool values keeps code relationships referential;
781
+ * Foundry never accepts a second list of copied string ids here.
782
+ */
783
+ readonly programmaticTools?: FoundryProgrammaticTools;
788
784
  }
789
- /** Why a run ended without finishing: it went to sleep, or it asked a question. */
790
- type FoundrySuspension = {
791
- readonly kind?: "sleep";
792
- readonly commandId: string;
793
- readonly wakeAt: string;
794
- } | {
795
- readonly kind: "question";
796
- readonly commandId: string;
797
- readonly delegationId: string;
798
- readonly question: string;
799
- };
800
- interface CreateAgentInstanceOptions {
801
- readonly id?: string;
802
- readonly workspaceId?: string;
803
- readonly context?: Readonly<Record<string, unknown>>;
804
- readonly installations?: ReadonlyArray<AgentInstallation>;
805
- readonly playbooks?: ReadonlyArray<AgentPlaybook>;
806
- }
807
- interface ProvisionAgentOptions extends CreateAgentInstanceOptions {
808
- readonly definitionId: string;
809
- readonly provisioningKey: string;
810
- }
811
- interface UpdateAgentInstanceOptions {
812
- readonly context?: Readonly<Record<string, unknown>>;
813
- readonly installations?: ReadonlyArray<AgentInstallation>;
814
- readonly playbooks?: ReadonlyArray<AgentPlaybook>;
815
- }
816
- interface CreateConversationOptions {
817
- readonly id?: string;
818
- readonly workspaceId?: string;
819
- readonly title?: string;
820
- readonly context?: Readonly<Record<string, unknown>>;
785
+ interface FoundryProgrammaticToolSelection {
786
+ /** One of the exact live tools supplied to the selector context. */
787
+ readonly tool: Tool<unknown>;
788
+ /** Optional valid interpreter identifier when the tool name is unsuitable. */
789
+ readonly name?: string;
790
+ /** Informational effect hint used by capability discovery. */
791
+ readonly readOnly?: boolean;
792
+ /** Optional capability group used by progressive discovery. */
793
+ readonly server?: string;
794
+ readonly serverDescription?: string;
795
+ readonly resultShape?: string;
821
796
  }
822
- interface UpdateConversationOptions {
823
- readonly title?: string;
824
- readonly context?: Readonly<Record<string, unknown>>;
797
+ interface FoundryProgrammaticToolContext {
798
+ readonly assembly: AgentAssemblyContext<FoundryRequest>;
799
+ readonly glove: IGloveRunnable;
800
+ /** Snapshot of every tool mounted before the programmatic surface itself. */
801
+ readonly tools: ReadonlyArray<Tool<unknown>>;
802
+ readonly workingEnvironment?: WorkingEnvironment;
803
+ readonly vfs?: EnvFsHandle;
825
804
  }
826
- declare class MemoryFoundryDataAdapter implements FoundryDataAdapter {
827
- readonly identifier: string;
828
- private readonly agents;
829
- private readonly agentsByProvisioningKey;
830
- private readonly subscriptions;
831
- private readonly inboundDeliveries;
832
- private readonly pendingInbound;
833
- private readonly activations;
834
- private readonly conversations;
835
- private readonly workspace;
836
- private readonly workingEnvironments;
837
- private readonly inbox;
838
- private readonly tasks;
839
- private readonly environment;
840
- private pendingAgents;
841
- private pendingSubscriptions;
842
- constructor(options?: {
843
- readonly identifier?: string;
844
- readonly environment?: ReadonlyArray<EnvironmentValue>;
845
- readonly agents?: ReadonlyArray<AgentInstance>;
846
- readonly conversations?: ReadonlyArray<Conversation>;
847
- readonly subscriptions?: ReadonlyArray<PlaybookSubscription>;
848
- readonly activations?: ReadonlyArray<FoundryActivationRecord>;
849
- });
850
- /** Resolve file-owned identities only after Foundry discovery has bound them. */
851
- private materializeSeeds;
852
- getAgent(id: string): Effect.Effect<AgentInstance | null, never, never>;
853
- putAgent(agent: AgentInstance): Effect.Effect<void, never, never>;
854
- listAgents(definitionId?: string): Effect.Effect<AgentInstance[], never, never>;
855
- provisionAgent(input: ProvisionAgentOptions): Effect.Effect<AgentInstance, never, never>;
856
- getPlaybookSubscription(id: string): Effect.Effect<PlaybookSubscription | null, never, never>;
857
- putPlaybookSubscription(subscription: PlaybookSubscription): Effect.Effect<void, never, never>;
858
- deletePlaybookSubscription(id: string): Effect.Effect<boolean, never, never>;
859
- listPlaybookSubscriptions(workspaceId?: string): Effect.Effect<PlaybookSubscription[], never, never>;
860
- getInboundDelivery(key: string): Effect.Effect<InboundDeliveryClaim | null, never, never>;
861
- claimInboundDelivery(key: string): Effect.Effect<boolean, never, never>;
862
- completeInboundDelivery(key: string, runIds: ReadonlyArray<string>): Effect.Effect<void, never, never>;
863
- releaseInboundDelivery(key: string): Effect.Effect<void, never, never>;
864
- putPendingInbound(record: FoundryPendingInbound): Effect.Effect<void, never, never>;
865
- deletePendingInbound(id: string): Effect.Effect<void, never, never>;
866
- listPendingInbound(): Effect.Effect<FoundryPendingInbound[], never, never>;
867
- getActivation(id: string): Effect.Effect<FoundryActivationRecord | null, never, never>;
868
- putActivation(activation: FoundryActivationRecord): Effect.Effect<void, never, never>;
869
- listActivations(workspaceId?: string): Effect.Effect<FoundryActivationRecord[], never, never>;
870
- getConversation(id: string): Effect.Effect<Conversation | null, never, never>;
871
- putConversation(conversation: Conversation): Effect.Effect<void, never, never>;
872
- listConversations(agentId: string): Effect.Effect<Conversation[], never, never>;
873
- getWorkspaceEntry(workspaceId: string, key: string): Effect.Effect<WorkspaceEntry | null, never, never>;
874
- putWorkspaceEntry(entry: WorkspaceEntry): Effect.Effect<void, never, never>;
875
- compareAndSetWorkspaceEntry(entry: WorkspaceEntry, expectedUpdatedAt: string | null): Effect.Effect<boolean, never, never>;
876
- listWorkspaceEntries(workspaceId: string): Effect.Effect<WorkspaceEntry[], never, never>;
877
- getWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner): Effect.Effect<EnvSnapshot | null, never, never>;
878
- putWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner, snapshot: EnvSnapshot): Effect.Effect<void, never, never>;
879
- putInboxItem(item: SharedInboxItem): Effect.Effect<void, never, never>;
880
- listInboxItems(workspaceId: string): Effect.Effect<SharedInboxItem[], never, never>;
881
- putTask(task: FoundryTask): Effect.Effect<void, never, never>;
882
- listTasks(workspaceId: string): Effect.Effect<FoundryTask[], never, never>;
883
- listEnvironment(scope: {
884
- readonly workspaceId: string;
885
- readonly agentId?: string;
886
- readonly conversationId?: string;
887
- }): Effect.Effect<EnvironmentValue[], never, never>;
805
+ interface FoundryProgrammaticTools {
806
+ /**
807
+ * Select direct live tool references. A selection may decorate its callable
808
+ * name and discovery metadata without replacing the underlying capability.
809
+ */
810
+ readonly select: (context: FoundryProgrammaticToolContext) => Resolvable<ReadonlyArray<Tool<unknown> | FoundryProgrammaticToolSelection>>;
811
+ /** Total underlying calls permitted during this assembled run. Default 50. */
812
+ readonly maxCalls?: number;
888
813
  }
889
- declare function createAgentInstance(definitionId: string, options?: CreateAgentInstanceOptions, provisioningKey?: string): AgentInstance;
890
- /** Code-authoring helper; instance data stores the referenced definition id. */
891
- declare function defineAgentInstance(definition: FoundryAgentDefinition, options?: CreateAgentInstanceOptions): AgentInstance;
892
- /** Rehydrate a durable adapter record into Foundry's immutable runtime shape. */
893
- declare function reconstructAgentInstance(agent: AgentInstance): AgentInstance;
894
- declare function createConversation(agent: AgentInstance, options?: CreateConversationOptions): Conversation;
814
+ type FoundryJavaScriptReplDefinition = FoundryReplBase & Readonly<{
815
+ readonly language: "javascript";
816
+ readonly session: JsSession;
817
+ readonly mount?: Omit<MountJsConfig, "session">;
818
+ }>;
819
+ type FoundryPythonReplDefinition = FoundryReplBase & Readonly<{
820
+ readonly language: "python";
821
+ readonly session: PySession;
822
+ readonly mount?: Omit<MountPyConfig, "session">;
823
+ }>;
824
+ type FoundryLispReplDefinition = FoundryReplBase & Readonly<{
825
+ readonly language: "lisp";
826
+ readonly session: LispSession;
827
+ readonly mount?: Omit<MountLispConfig, "session">;
828
+ }>;
829
+ type FoundryReplDefinition = FoundryJavaScriptReplDefinition | FoundryPythonReplDefinition | FoundryLispReplDefinition;
830
+ type DefineFoundryReplOptions = Omit<FoundryJavaScriptReplDefinition, typeof FOUNDRY_REPL_BRAND> | Omit<FoundryPythonReplDefinition, typeof FOUNDRY_REPL_BRAND> | Omit<FoundryLispReplDefinition, typeof FOUNDRY_REPL_BRAND>;
831
+ declare function defineRepl(options: DefineFoundryReplOptions): FoundryReplDefinition;
832
+ type FoundryMountedRepl = Readonly<{
833
+ readonly language: "javascript";
834
+ readonly session: JsSession;
835
+ }> | Readonly<{
836
+ readonly language: "python";
837
+ readonly session: PySession;
838
+ }> | Readonly<{
839
+ readonly language: "lisp";
840
+ readonly session: LispSession;
841
+ }>;
895
842
 
896
- declare const FOUNDRY_SHARED_TOOL_BRAND: unique symbol;
897
- declare const FOUNDRY_AGENT_APPLICATION_BRAND: unique symbol;
898
- declare const FOUNDRY_MCP_BRAND: unique symbol;
899
- declare const FOUNDRY_MEMORY_BRAND: unique symbol;
900
- type AgentInstallationKind = "tool" | "application" | "mcp";
901
- type FoundryCapabilityKind = AgentInstallationKind | "memory";
902
- interface AgentInstallation {
903
- readonly kind: AgentInstallationKind;
904
- readonly id: string;
905
- /** Durable account selection; code authoring supplies this through an AccountReference. */
906
- readonly accountId?: string;
907
- readonly config?: unknown;
908
- }
909
- type FoundryInstallable = FoundrySharedTool<any> | FoundryAgentApplication | FoundryMcp;
910
- /** Create persisted installation data from a code definition. */
911
- type DefinitionConfigInput<TDefinition> = TDefinition extends {
912
- readonly config?: infer TSchema;
913
- } ? TSchema extends z.ZodType ? z.input<TSchema> : never : never;
914
- interface InstallationSelection {
915
- readonly account?: AccountReference;
916
- }
917
- declare function install<TDefinition extends FoundryInstallable>(capability: TDefinition, ...configuration: [DefinitionConfigInput<TDefinition>] extends [never] ? [config?: never, selection?: InstallationSelection] : [config: DefinitionConfigInput<TDefinition>, selection?: InstallationSelection]): AgentInstallation;
918
- declare function installationKey(installation: AgentInstallation): string;
919
- interface AgentMountBaseContext {
843
+ declare const FOUNDRY_LAYER_BRAND: unique symbol;
844
+ declare const FOUNDRY_SUBSCRIBER_BRAND: unique symbol;
845
+ interface FoundrySurfaceContext<TInput = unknown> {
920
846
  readonly definitionId: string;
921
847
  readonly agentId: string;
922
848
  readonly conversationId: string;
923
849
  readonly workspaceId: string;
924
850
  readonly runId: string;
925
- readonly input: unknown;
851
+ readonly input: TInput;
926
852
  readonly request: FoundryRequest;
927
853
  readonly message: Message;
928
854
  readonly messageInput: FoundryMessageInput;
@@ -930,524 +856,138 @@ interface AgentMountBaseContext {
930
856
  readonly history: ReadonlyArray<Message>;
931
857
  readonly messages: ReadonlyArray<Message>;
932
858
  readonly glove: IGloveRunnable;
933
- readonly store: StoreAdapter;
859
+ readonly workingEnvironment?: WorkingEnvironment;
860
+ readonly vfs?: FoundryVfsHandle;
861
+ readonly repl?: FoundryMountedRepl;
862
+ readonly signal: AbortSignal;
934
863
  readonly emit: (event: {
935
864
  type: string;
936
865
  data?: unknown;
937
866
  }) => void;
938
867
  }
939
- interface AgentInstallContext<TConfig = unknown> extends AgentMountBaseContext {
940
- readonly installation: AgentInstallation;
941
- readonly config: TConfig;
942
- readonly accountId?: string;
943
- readonly withAccountSession?: <A>(operation: string, use: (session: unknown) => Effect.Effect<A, unknown, never>) => Effect.Effect<A, unknown, never>;
944
- }
945
- interface AgentDefinitionSurfaceContext extends AgentMountBaseContext {
946
- readonly surface: {
947
- readonly kind: "memory";
948
- readonly id: string;
949
- };
950
- readonly config: unknown;
951
- }
952
- /** Pure application-definition context. It deliberately exposes no Glove. */
953
- type AgentApplicationInstallContext<TConfig = unknown> = Omit<AgentInstallContext<TConfig>, "glove" | "store">;
954
- interface AgentApplicationContribution {
955
- /** Tools Foundry will mount after the installer returns. */
956
- readonly tools?: ReadonlyArray<GloveFoldArgs<any>>;
957
- }
958
- interface ConfiguredCapability<TConfigSchema extends z.ZodType | undefined = z.ZodType | undefined> {
868
+ type FoundrySurfaceCleanup = () => void | Promise<void> | Effect.Effect<void, unknown, never>;
869
+ interface FoundryLayerOptions<TConfigSchema extends z.ZodType | undefined = undefined> {
959
870
  /** @deprecated File-routed definitions derive identity from their filename. */
960
871
  readonly id?: string;
961
872
  readonly description: string;
962
873
  readonly config?: TConfigSchema;
874
+ /**
875
+ * Mount any Glove-native package or application concern onto the compiled
876
+ * runnable. Mesh, memory subagent composition, scratchpads, image surfaces,
877
+ * voice bridges and future Glove packages all fit through this seam.
878
+ */
879
+ readonly setup: (context: FoundrySurfaceContext & {
880
+ readonly config: TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown;
881
+ }) => Effect.Effect<void | FoundrySurfaceCleanup, unknown, never>;
963
882
  }
964
- type SharedToolOptions<TInput = unknown, TConfigSchema extends z.ZodType | undefined = undefined> = ConfiguredCapability<TConfigSchema> & ({
965
- readonly tool: GloveFoldArgs<TInput>;
966
- readonly create?: never;
967
- } | {
968
- readonly tool?: never;
969
- readonly create: (context: AgentInstallContext<TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown>) => Effect.Effect<GloveFoldArgs<TInput>, unknown, never>;
970
- });
971
- type FoundrySharedTool<TInput = unknown, TConfigSchema extends z.ZodType | undefined = any> = Readonly<SharedToolOptions<TInput, TConfigSchema>> & {
883
+ type FoundryLayer<TConfigSchema extends z.ZodType | undefined = undefined> = Readonly<FoundryLayerOptions<TConfigSchema>> & {
972
884
  readonly id: string;
973
- readonly [FOUNDRY_SHARED_TOOL_BRAND]: true;
885
+ readonly [FOUNDRY_LAYER_BRAND]: true;
974
886
  };
975
- declare function defineSharedTool<TInput, const TConfigSchema extends z.ZodType | undefined = undefined>(options: SharedToolOptions<TInput, TConfigSchema>): FoundrySharedTool<TInput, TConfigSchema>;
976
- interface AgentApplicationOptions<TConfigSchema extends z.ZodType | undefined = undefined> extends ConfiguredCapability<TConfigSchema> {
977
- /** Inbound transmission mechanisms owned by this application. */
978
- readonly inbound?: ReadonlyArray<AnyFoundryTransmission>;
979
- /** Outbound transmission mechanisms mounted as tools when installed. */
980
- readonly outbound?: ReadonlyArray<AnyFoundryTransmission>;
981
- /** Mixed/bidirectional definitions; prefer inbound/outbound for clarity. */
982
- readonly transmissions?: ReadonlyArray<AnyFoundryTransmission>;
983
- /** Purpose-built long-lived provider connections for inbound transmissions. */
984
- readonly connections?: ReadonlyArray<FoundryApplicationConnection>;
985
- readonly install?: (context: AgentApplicationInstallContext<TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown>) => Effect.Effect<AgentApplicationContribution | void, unknown, never>;
887
+ declare function defineLayer<TConfigSchema extends z.ZodType | undefined = undefined>(options: FoundryLayerOptions<TConfigSchema>): FoundryLayer<TConfigSchema>;
888
+ interface FoundryLayerReference<TLayer extends FoundryLayer<any> = FoundryLayer<any>> {
889
+ readonly layer: TLayer;
890
+ readonly config?: TLayer extends FoundryLayer<infer TSchema> ? TSchema extends z.ZodType ? z.input<TSchema> : never : never;
986
891
  }
987
- type FoundryAgentApplication<TConfigSchema extends z.ZodType | undefined = any> = Readonly<AgentApplicationOptions<TConfigSchema>> & {
988
- readonly id: string;
989
- readonly [FOUNDRY_AGENT_APPLICATION_BRAND]: true;
990
- };
991
- declare function defineAgentApplication<const TConfigSchema extends z.ZodType | undefined = undefined>(options: AgentApplicationOptions<TConfigSchema>): FoundryAgentApplication<TConfigSchema>;
992
- /** Concise authoring name for an agent-local application definition. */
993
- declare const defineApp: typeof defineAgentApplication;
994
- type FoundryApp = FoundryAgentApplication;
995
- interface FoundryMcpOptions<TConfigSchema extends z.ZodType | undefined = undefined> {
892
+ type FoundryLayerSelection = FoundryLayerReference<any> | FoundryLayer<any>;
893
+ /** Select a configured layer with schema-inferred input. */
894
+ declare function configureLayer<TLayer extends FoundryLayer<any>>(layer: TLayer, config: FoundryLayerReference<TLayer>["config"]): FoundryLayerReference<TLayer>;
895
+ interface FoundrySubscriberOptions {
996
896
  /** @deprecated File-routed definitions derive identity from their filename. */
997
897
  readonly id?: string;
998
- readonly description?: string;
999
- readonly config?: TConfigSchema;
1000
- /**
1001
- * Static catalogue metadata or a lazy, instance-configured resolver.
1002
- *
1003
- * The resolver receives decoded installation data but never credentials.
1004
- * Auth remains the responsibility of the agent-owned `mcpAdapter` and is
1005
- * resolved only when glove-mcp opens a connection.
1006
- */
1007
- readonly entry: McpCatalogueEntryWithoutId | ((context: AgentApplicationInstallContext<TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown>) => McpCatalogueEntryWithoutId | Promise<McpCatalogueEntryWithoutId> | Effect.Effect<McpCatalogueEntryWithoutId, unknown, never>);
1008
- }
1009
- type McpCatalogueEntryWithoutId = McpCatalogueEntry extends infer Entry ? Entry extends unknown ? Omit<Entry, "id"> : never : never;
1010
- type FoundryMcp<TConfigSchema extends z.ZodType | undefined = any> = Readonly<FoundryMcpOptions<TConfigSchema>> & {
1011
- readonly id: string;
1012
- readonly [FOUNDRY_MCP_BRAND]: true;
1013
- };
1014
- declare function defineMcp<const TConfigSchema extends z.ZodType | undefined = undefined>(options: FoundryMcpOptions<TConfigSchema>): FoundryMcp<TConfigSchema>;
1015
- type MemoryAdapterFactory<A> = (context: AgentDefinitionSurfaceContext) => Effect.Effect<A, unknown, never>;
1016
- interface MemorySurfaceOptions {
1017
- readonly access?: "reader" | "curator";
1018
- readonly tools?: MemoryToolOptions["tools"];
1019
- }
1020
- interface FoundryMemoryProfileOptions<TConfigSchema extends z.ZodType | undefined = undefined> extends ConfiguredCapability<TConfigSchema> {
1021
- readonly entity?: MemorySurfaceOptions & {
1022
- readonly adapter: MemoryAdapterFactory<EntityMemoryAdapter>;
1023
- };
1024
- readonly episodic?: MemorySurfaceOptions & {
1025
- readonly adapter: MemoryAdapterFactory<EpisodicMemoryAdapter>;
1026
- };
1027
- readonly resources?: MemorySurfaceOptions & {
1028
- readonly adapter: MemoryAdapterFactory<ResourceFsAdapter>;
1029
- };
1030
- /** Ambient context remains on the main agent, matching glove-memory. */
1031
- readonly context?: {
1032
- readonly adapter: MemoryAdapterFactory<ContextAdapter>;
1033
- readonly tools?: MemoryToolOptions["tools"];
1034
- };
1035
- /** Escape hatch for subagent-delegated or application-specific composition. */
1036
- readonly mount?: (context: AgentDefinitionSurfaceContext) => Effect.Effect<void, unknown, never>;
898
+ readonly description: string;
899
+ readonly create: SubscriberAdapter | ((context: FoundrySurfaceContext) => SubscriberAdapter | Promise<SubscriberAdapter> | Effect.Effect<SubscriberAdapter, unknown, never>);
1037
900
  }
1038
- type FoundryMemoryProfile<TConfigSchema extends z.ZodType | undefined = any> = Readonly<FoundryMemoryProfileOptions<TConfigSchema>> & {
901
+ type FoundrySubscriber = Readonly<FoundrySubscriberOptions> & {
1039
902
  readonly id: string;
1040
- readonly [FOUNDRY_MEMORY_BRAND]: true;
903
+ readonly [FOUNDRY_SUBSCRIBER_BRAND]: true;
1041
904
  };
1042
- declare function defineMemory<const TConfigSchema extends z.ZodType | undefined = undefined>(options: FoundryMemoryProfileOptions<TConfigSchema>): FoundryMemoryProfile<TConfigSchema>;
1043
- interface FoundryCapabilityRegistry {
1044
- readonly tools: ReadonlyArray<FoundrySharedTool<any>>;
1045
- readonly applications: ReadonlyArray<FoundryAgentApplication>;
1046
- readonly mcp: ReadonlyArray<FoundryMcp>;
1047
- readonly memory: ReadonlyArray<FoundryMemoryProfile>;
905
+ declare function defineSubscriber(options: FoundrySubscriberOptions): FoundrySubscriber;
906
+ type FoundrySubscriberSelection = FoundrySubscriber;
907
+ interface FoundryNativeRegistry {
908
+ readonly layers: ReadonlyArray<FoundryLayer<any>>;
909
+ readonly subscribers: ReadonlyArray<FoundrySubscriber>;
1048
910
  }
1049
- interface FoundryCapabilityManifestEntry {
911
+ interface FoundryNativeManifestEntry {
1050
912
  readonly id: string;
1051
- readonly kind: FoundryCapabilityKind;
913
+ readonly kind: "layer" | "subscriber";
1052
914
  readonly description: string;
1053
- readonly ownership: "instance" | "definition";
1054
915
  readonly file?: string;
1055
916
  }
1056
- interface FoundryCapabilityManifest {
1057
- readonly tools: ReadonlyArray<FoundryCapabilityManifestEntry>;
1058
- readonly applications: ReadonlyArray<FoundryCapabilityManifestEntry>;
1059
- readonly mcp: ReadonlyArray<FoundryCapabilityManifestEntry>;
1060
- readonly memory: ReadonlyArray<FoundryCapabilityManifestEntry>;
1061
- }
1062
- declare const EMPTY_CAPABILITY_REGISTRY: FoundryCapabilityRegistry;
1063
- interface McpAdapterFactory {
1064
- (context: Omit<AgentInstallContext, "installation" | "config"> & {
1065
- readonly installed: ReadonlyArray<FoundryMcp>;
1066
- /** Fully decoded, per-instance MCP selections for this assembly. */
1067
- readonly resolved: ReadonlyArray<FoundryResolvedMcp>;
1068
- }): Effect.Effect<McpAdapter, unknown, never>;
1069
- }
1070
- interface FoundryResolvedMcp {
1071
- readonly definition: FoundryMcp;
1072
- readonly installation: AgentInstallation;
1073
- readonly config: unknown;
1074
- readonly entry: McpCatalogueEntry;
1075
- }
1076
- declare function isInboxCapableStore(store: StoreAdapter): store is StoreAdapter & Required<Pick<StoreAdapter, "getInboxItems" | "addInboxItem" | "updateInboxItem" | "getResolvedInboxItems">>;
1077
- interface FoundryMemoryReference<TProfile extends FoundryMemoryProfile<any> = FoundryMemoryProfile<any>> {
1078
- readonly profile: TProfile;
1079
- readonly config: DefinitionConfigInput<TProfile>;
1080
- }
1081
- type FoundryMemorySelection = FoundryMemoryProfile | FoundryMemoryReference;
1082
- /** Select a configured memory profile with schema-inferred input. */
1083
- declare function configureMemory<TProfile extends FoundryMemoryProfile<any>>(profile: TProfile, config: DefinitionConfigInput<TProfile>): FoundryMemoryReference<TProfile>;
1084
- interface MountAgentDefinitionMemoryOptions {
1085
- readonly registry: FoundryCapabilityRegistry;
1086
- readonly memory: ReadonlyArray<FoundryMemorySelection>;
1087
- readonly context: Omit<AgentDefinitionSurfaceContext, "surface" | "config">;
1088
- }
1089
- /** Mount definition-owned memory surfaces for one assembled run. */
1090
- declare function mountAgentDefinitionMemory(options: MountAgentDefinitionMemoryOptions): Effect.Effect<void, unknown, never>;
1091
- interface InstallRegistryOptions {
1092
- readonly registry: FoundryCapabilityRegistry;
1093
- readonly installations: ReadonlyArray<AgentInstallation>;
1094
- readonly context: Omit<AgentInstallContext, "installation" | "config">;
1095
- readonly mcpAdapter?: McpAdapterFactory;
1096
- readonly accountSessions?: FoundryAccountSessionAdapter;
1097
- }
1098
- interface FoundryAccountSessionAdapter {
1099
- readonly identifier: string;
1100
- withSession<A>(request: {
1101
- readonly accountId: string;
1102
- readonly operation: string;
1103
- readonly agentId: string;
1104
- readonly conversationId: string;
1105
- readonly workspaceId: string;
1106
- }, use: (session: unknown) => Effect.Effect<A, unknown, never>): Effect.Effect<A, unknown, never>;
917
+ interface FoundryNativeManifest {
918
+ readonly layers: ReadonlyArray<FoundryNativeManifestEntry>;
919
+ readonly subscribers: ReadonlyArray<FoundryNativeManifestEntry>;
1107
920
  }
1108
- /** Install only explicitly selected capabilities onto a running Glove. */
1109
- declare function installRegistry(options: InstallRegistryOptions): Effect.Effect<ReadonlyArray<AgentInstallation>, unknown, never>;
1110
- declare function isFoundryCapability(value: unknown): boolean;
921
+ declare const EMPTY_NATIVE_REGISTRY: FoundryNativeRegistry;
922
+ declare function mountFoundrySurfaces(options: {
923
+ readonly registry: FoundryNativeRegistry;
924
+ readonly layers?: ReadonlyArray<FoundryLayerSelection>;
925
+ readonly subscribers?: ReadonlyArray<FoundrySubscriberSelection | SubscriberAdapter>;
926
+ readonly context: FoundrySurfaceContext;
927
+ }): Promise<() => Promise<void>>;
928
+ declare function isFoundryLayer(value: unknown): value is FoundryLayer;
929
+ declare function isFoundrySubscriber(value: unknown): value is FoundrySubscriber;
1111
930
 
1112
- declare const FOUNDRY_WORKING_ENVIRONMENT_BRAND: unique symbol;
1113
- declare const FOUNDRY_REPL_BRAND: unique symbol;
1114
- type FoundryVfs = Vfs;
1115
- type FoundryVfsHandle = EnvFsHandle;
1116
- interface FoundryWorkingEnvironmentPersistenceContext {
1117
- readonly definitionId: string;
1118
- readonly agentId: string;
1119
- readonly conversationId: string;
1120
- readonly workspaceId: string;
1121
- readonly runId: string;
1122
- readonly data: FoundryDataAdapter;
1123
- readonly signal: AbortSignal;
1124
- }
931
+ type FoundryAgentComponent = FoundrySharedTool<any> | FoundryAgentApplication | FoundryMcp | FoundryMemoryProfile | FoundryLayer<any> | FoundrySubscriber;
1125
932
  /**
1126
- * Storage is deliberately adapter-owned. Foundry never chooses a database,
1127
- * object store, locking policy, or credential lifecycle for an environment.
933
+ * A colocated `*.tool.ts` may export the Glove tool body directly. Foundry
934
+ * supplies the runtime tool name from the file route, so the authored module
935
+ * never has to repeat its identity as a string.
1128
936
  */
1129
- interface FoundryWorkingEnvironmentPersistenceAdapter {
1130
- readonly identifier: string;
1131
- readonly load: (context: FoundryWorkingEnvironmentPersistenceContext) => Resolvable<EnvSnapshot | null>;
1132
- readonly save: (snapshot: EnvSnapshot, context: FoundryWorkingEnvironmentPersistenceContext) => Resolvable<void>;
1133
- }
1134
- interface FoundryWorkingEnvironmentCreateContext {
1135
- readonly assembly: AgentAssemblyContext<FoundryRequest>;
1136
- readonly snapshot: EnvSnapshot | null;
1137
- }
1138
- interface DefineFoundryWorkingEnvironmentOptions {
1139
- /**
1140
- * Build the native Glove environment. Use this when creation itself needs
1141
- * custom logic. The loaded snapshot is provided but never applied implicitly.
1142
- */
1143
- readonly create?: (context: FoundryWorkingEnvironmentCreateContext) => Resolvable<WorkingEnvironment>;
1144
- /**
1145
- * Native environment options. When persistence returns a snapshot and no
1146
- * filesystem is supplied, Foundry restores that snapshot automatically.
1147
- */
1148
- readonly options?: CreateWorkingEnvironmentOptions | ((context: FoundryWorkingEnvironmentCreateContext) => Resolvable<CreateWorkingEnvironmentOptions>);
1149
- readonly persistence?: FoundryWorkingEnvironmentPersistenceAdapter;
1150
- /** Native mount behavior: prompt priming and optional tool prefix. */
1151
- readonly mount?: Omit<MountWorkingEnvironmentConfig, "env">;
1152
- /** Close worker/adaptor resources after the run. Default true. */
1153
- readonly close?: boolean;
937
+ type FoundryToolBody = Omit<GloveFoldArgs<any>, "name">;
938
+ interface FoundryAgentComposition {
939
+ readonly capabilities: FoundryCapabilityRegistry;
940
+ readonly native: FoundryNativeRegistry;
1154
941
  }
1155
- type FoundryWorkingEnvironmentDefinition = Readonly<DefineFoundryWorkingEnvironmentOptions> & {
1156
- readonly [FOUNDRY_WORKING_ENVIRONMENT_BRAND]: true;
1157
- };
1158
- declare function defineWorkingEnvironment(options?: DefineFoundryWorkingEnvironmentOptions): FoundryWorkingEnvironmentDefinition;
942
+ type FoundryCompositionSource = FoundryAgentComponent | FoundryToolBody | FoundryAgentComposition | ReadonlyArray<FoundryCompositionSource> | (() => FoundryCompositionSource) | false | null | undefined;
1159
943
  /**
1160
- * Convenience persistence over the configured FoundryDataAdapter's private
1161
- * snapshot seam. VFS contents never become public workspace entries.
944
+ * Compose colocated, headless agent parts into one immutable catalogue.
945
+ * Functions are factories, not runtime installers: they return definitions and
946
+ * never receive or mutate a Glove instance.
1162
947
  */
1163
- declare function foundryDataEnvironmentPersistence(options?: {
1164
- readonly scope?: "agent" | "conversation";
1165
- }): FoundryWorkingEnvironmentPersistenceAdapter;
1166
- interface FoundryReplBase {
1167
- readonly [FOUNDRY_REPL_BRAND]: true;
1168
- /**
1169
- * Project an explicit set of the fully assembled agent's tools into the
1170
- * sandbox as ordinary functions. Selection happens after applications,
1171
- * installed capabilities, memory, mesh, calls, and `configure` have mounted.
1172
- *
1173
- * Returning the actual tool values keeps code relationships referential;
1174
- * Foundry never accepts a second list of copied string ids here.
1175
- */
1176
- readonly programmaticTools?: FoundryProgrammaticTools;
1177
- }
1178
- interface FoundryProgrammaticToolSelection {
1179
- /** One of the exact live tools supplied to the selector context. */
1180
- readonly tool: Tool<unknown>;
1181
- /** Optional valid interpreter identifier when the tool name is unsuitable. */
1182
- readonly name?: string;
1183
- /** Informational effect hint used by capability discovery. */
1184
- readonly readOnly?: boolean;
1185
- /** Optional capability group used by progressive discovery. */
1186
- readonly server?: string;
1187
- readonly serverDescription?: string;
1188
- readonly resultShape?: string;
1189
- }
1190
- interface FoundryProgrammaticToolContext {
1191
- readonly assembly: AgentAssemblyContext<FoundryRequest>;
1192
- readonly glove: IGloveRunnable;
1193
- /** Snapshot of every tool mounted before the programmatic surface itself. */
1194
- readonly tools: ReadonlyArray<Tool<unknown>>;
1195
- readonly workingEnvironment?: WorkingEnvironment;
1196
- readonly vfs?: EnvFsHandle;
1197
- }
1198
- interface FoundryProgrammaticTools {
1199
- /**
1200
- * Select direct live tool references. A selection may decorate its callable
1201
- * name and discovery metadata without replacing the underlying capability.
1202
- */
1203
- readonly select: (context: FoundryProgrammaticToolContext) => Resolvable<ReadonlyArray<Tool<unknown> | FoundryProgrammaticToolSelection>>;
1204
- /** Total underlying calls permitted during this assembled run. Default 50. */
1205
- readonly maxCalls?: number;
1206
- }
1207
- type FoundryJavaScriptReplDefinition = FoundryReplBase & Readonly<{
1208
- readonly language: "javascript";
1209
- readonly session: JsSession;
1210
- readonly mount?: Omit<MountJsConfig, "session">;
1211
- }>;
1212
- type FoundryPythonReplDefinition = FoundryReplBase & Readonly<{
1213
- readonly language: "python";
1214
- readonly session: PySession;
1215
- readonly mount?: Omit<MountPyConfig, "session">;
1216
- }>;
1217
- type FoundryLispReplDefinition = FoundryReplBase & Readonly<{
1218
- readonly language: "lisp";
1219
- readonly session: LispSession;
1220
- readonly mount?: Omit<MountLispConfig, "session">;
1221
- }>;
1222
- type FoundryReplDefinition = FoundryJavaScriptReplDefinition | FoundryPythonReplDefinition | FoundryLispReplDefinition;
1223
- type DefineFoundryReplOptions = Omit<FoundryJavaScriptReplDefinition, typeof FOUNDRY_REPL_BRAND> | Omit<FoundryPythonReplDefinition, typeof FOUNDRY_REPL_BRAND> | Omit<FoundryLispReplDefinition, typeof FOUNDRY_REPL_BRAND>;
1224
- declare function defineRepl(options: DefineFoundryReplOptions): FoundryReplDefinition;
1225
- type FoundryMountedRepl = Readonly<{
1226
- readonly language: "javascript";
1227
- readonly session: JsSession;
1228
- }> | Readonly<{
1229
- readonly language: "python";
1230
- readonly session: PySession;
1231
- }> | Readonly<{
1232
- readonly language: "lisp";
1233
- readonly session: LispSession;
1234
- }>;
948
+ declare function composeAgent(...sources: ReadonlyArray<FoundryCompositionSource>): FoundryAgentComposition;
949
+ declare const EMPTY_AGENT_COMPOSITION: FoundryAgentComposition;
1235
950
 
1236
- declare const FOUNDRY_LAYER_BRAND: unique symbol;
1237
- declare const FOUNDRY_SUBSCRIBER_BRAND: unique symbol;
1238
- interface FoundrySurfaceContext<TInput = unknown> {
1239
- readonly definitionId: string;
1240
- readonly agentId: string;
1241
- readonly conversationId: string;
1242
- readonly workspaceId: string;
1243
- readonly runId: string;
1244
- readonly input: TInput;
1245
- readonly request: FoundryRequest;
1246
- readonly message: Message;
1247
- readonly messageInput: FoundryMessageInput;
1248
- readonly messageText: string;
1249
- readonly history: ReadonlyArray<Message>;
1250
- readonly messages: ReadonlyArray<Message>;
1251
- readonly glove: IGloveRunnable;
1252
- readonly workingEnvironment?: WorkingEnvironment;
1253
- readonly vfs?: FoundryVfsHandle;
1254
- readonly repl?: FoundryMountedRepl;
1255
- readonly signal: AbortSignal;
1256
- readonly emit: (event: {
1257
- type: string;
1258
- data?: unknown;
1259
- }) => void;
1260
- }
1261
- type FoundrySurfaceCleanup = () => void | Promise<void> | Effect.Effect<void, unknown, never>;
1262
- interface FoundryLayerOptions<TConfigSchema extends z.ZodType | undefined = undefined> {
1263
- /** @deprecated File-routed definitions derive identity from their filename. */
1264
- readonly id?: string;
1265
- readonly description: string;
1266
- readonly config?: TConfigSchema;
1267
- /**
1268
- * Mount any Glove-native package or application concern onto the compiled
1269
- * runnable. Mesh, memory subagent composition, scratchpads, image surfaces,
1270
- * voice bridges and future Glove packages all fit through this seam.
1271
- */
1272
- readonly setup: (context: FoundrySurfaceContext & {
1273
- readonly config: TConfigSchema extends z.ZodType ? z.output<TConfigSchema> : unknown;
1274
- }) => Effect.Effect<void | FoundrySurfaceCleanup, unknown, never>;
1275
- }
1276
- type FoundryLayer<TConfigSchema extends z.ZodType | undefined = undefined> = Readonly<FoundryLayerOptions<TConfigSchema>> & {
1277
- readonly id: string;
1278
- readonly [FOUNDRY_LAYER_BRAND]: true;
1279
- };
1280
- declare function defineLayer<TConfigSchema extends z.ZodType | undefined = undefined>(options: FoundryLayerOptions<TConfigSchema>): FoundryLayer<TConfigSchema>;
1281
- interface FoundryLayerReference<TLayer extends FoundryLayer<any> = FoundryLayer<any>> {
1282
- readonly layer: TLayer;
1283
- readonly config?: TLayer extends FoundryLayer<infer TSchema> ? TSchema extends z.ZodType ? z.input<TSchema> : never : never;
1284
- }
1285
- type FoundryLayerSelection = FoundryLayerReference<any> | FoundryLayer<any>;
1286
- /** Select a configured layer with schema-inferred input. */
1287
- declare function configureLayer<TLayer extends FoundryLayer<any>>(layer: TLayer, config: FoundryLayerReference<TLayer>["config"]): FoundryLayerReference<TLayer>;
1288
- interface FoundrySubscriberOptions {
1289
- /** @deprecated File-routed definitions derive identity from their filename. */
1290
- readonly id?: string;
1291
- readonly description: string;
1292
- readonly create: SubscriberAdapter | ((context: FoundrySurfaceContext) => SubscriberAdapter | Promise<SubscriberAdapter> | Effect.Effect<SubscriberAdapter, unknown, never>);
1293
- }
1294
- type FoundrySubscriber = Readonly<FoundrySubscriberOptions> & {
1295
- readonly id: string;
1296
- readonly [FOUNDRY_SUBSCRIBER_BRAND]: true;
951
+ declare const FOUNDRY_SCHEDULE_BRAND: unique symbol;
952
+ type FoundryScheduleTimingInput = {
953
+ readonly kind: "at";
954
+ readonly at: string;
955
+ } | {
956
+ readonly kind: "after";
957
+ readonly duration: string;
958
+ } | {
959
+ readonly kind: "every";
960
+ readonly interval: string;
961
+ } | {
962
+ readonly kind: "cron";
963
+ readonly expression: string;
964
+ readonly timezone?: string;
1297
965
  };
1298
- declare function defineSubscriber(options: FoundrySubscriberOptions): FoundrySubscriber;
1299
- type FoundrySubscriberSelection = FoundrySubscriber;
1300
- interface FoundryNativeRegistry {
1301
- readonly layers: ReadonlyArray<FoundryLayer<any>>;
1302
- readonly subscribers: ReadonlyArray<FoundrySubscriber>;
1303
- }
1304
- interface FoundryNativeManifestEntry {
1305
- readonly id: string;
1306
- readonly kind: "layer" | "subscriber";
1307
- readonly description: string;
1308
- readonly file?: string;
1309
- }
1310
- interface FoundryNativeManifest {
1311
- readonly layers: ReadonlyArray<FoundryNativeManifestEntry>;
1312
- readonly subscribers: ReadonlyArray<FoundryNativeManifestEntry>;
1313
- }
1314
- declare const EMPTY_NATIVE_REGISTRY: FoundryNativeRegistry;
1315
- declare function mountFoundrySurfaces(options: {
1316
- readonly registry: FoundryNativeRegistry;
1317
- readonly layers?: ReadonlyArray<FoundryLayerSelection>;
1318
- readonly subscribers?: ReadonlyArray<FoundrySubscriberSelection | SubscriberAdapter>;
1319
- readonly context: FoundrySurfaceContext;
1320
- }): Promise<() => Promise<void>>;
1321
- declare function isFoundryLayer(value: unknown): value is FoundryLayer;
1322
- declare function isFoundrySubscriber(value: unknown): value is FoundrySubscriber;
1323
-
1324
- type FoundryAgentComponent = FoundrySharedTool<any> | FoundryAgentApplication | FoundryMcp | FoundryMemoryProfile | FoundryLayer<any> | FoundrySubscriber;
1325
- /**
1326
- * A colocated `*.tool.ts` may export the Glove tool body directly. Foundry
1327
- * supplies the runtime tool name from the file route, so the authored module
1328
- * never has to repeat its identity as a string.
1329
- */
1330
- type FoundryToolBody = Omit<GloveFoldArgs<any>, "name">;
1331
- interface FoundryAgentComposition {
1332
- readonly capabilities: FoundryCapabilityRegistry;
1333
- readonly native: FoundryNativeRegistry;
1334
- }
1335
- type FoundryCompositionSource = FoundryAgentComponent | FoundryToolBody | FoundryAgentComposition | ReadonlyArray<FoundryCompositionSource> | (() => FoundryCompositionSource) | false | null | undefined;
1336
- /**
1337
- * Compose colocated, headless agent parts into one immutable catalogue.
1338
- * Functions are factories, not runtime installers: they return definitions and
1339
- * never receive or mutate a Glove instance.
1340
- */
1341
- declare function composeAgent(...sources: ReadonlyArray<FoundryCompositionSource>): FoundryAgentComposition;
1342
- declare const EMPTY_AGENT_COMPOSITION: FoundryAgentComposition;
1343
-
1344
- /**
1345
- * A sibling agent this one may hand work to, named by its route
1346
- * (`"coder"` for `agents/coder/agent.ts`). Delegates are named rather than
1347
- * imported so the delegating agent's process never loads the worker's
1348
- * dependencies: a fast voice agent should not start up carrying a sandbox SDK.
1349
- */
1350
- type FoundryDelegate = string | FoundryDelegateOptions;
1351
- interface FoundryDelegateOptions {
1352
- /** Route of the worker definition. */
1353
- readonly agent: string;
1354
- /** What the worker is for. The delegating model reads this to choose. */
1355
- readonly description?: string;
1356
- }
1357
- type FoundryDelegationStatus = "working" | "waiting" | "completed" | "failed" | "cancelled";
1358
- /**
1359
- * One handed-off task. Its id is also the worker conversation's id, and the
1360
- * record lives on that conversation's `context.delegation`.
1361
- */
1362
- interface FoundryDelegation {
1363
- readonly id: string;
1364
- /** Route of the worker definition. */
1365
- readonly to: string;
1366
- /** The worker instance: one per delegating instance and route. */
1367
- readonly workerAgentId: string;
1368
- readonly workspaceId: string;
1369
- readonly from: {
1370
- readonly definitionId: string;
1371
- readonly agentId: string;
1372
- readonly conversationId: string;
1373
- readonly runId: string;
1374
- };
1375
- readonly task: string;
1376
- readonly status: FoundryDelegationStatus;
1377
- /** The open question while status is "waiting". */
1378
- readonly question?: string;
1379
- readonly result?: string;
1380
- readonly error?: string;
1381
- /**
1382
- * Bookkeeping: an update for the delegating conversation, or replies for the
1383
- * worker, not handed over yet. Foundry hands them over again after a restart.
1384
- */
1385
- readonly undelivered?: "result" | "question" | "failed";
1386
- readonly pendingReplies?: ReadonlyArray<string>;
1387
- readonly createdAt: string;
1388
- readonly updatedAt: string;
1389
- }
1390
- /** What reaches the delegating conversation. */
1391
- type FoundryDelegationUpdate = {
1392
- readonly kind: "result";
1393
- readonly delegationId: string;
1394
- readonly agent: string;
1395
- readonly task: string;
1396
- readonly result: string;
966
+ type FoundryScheduleTiming = {
967
+ readonly kind: "at";
968
+ readonly at: string;
1397
969
  } | {
1398
- readonly kind: "question";
1399
- readonly delegationId: string;
1400
- readonly agent: string;
1401
- readonly task: string;
1402
- readonly question: string;
970
+ readonly kind: "every";
971
+ readonly intervalMs: number;
1403
972
  } | {
1404
- readonly kind: "failed";
1405
- readonly delegationId: string;
1406
- readonly agent: string;
1407
- readonly task: string;
1408
- readonly error: string;
973
+ readonly kind: "cron";
974
+ readonly expression: string;
975
+ readonly timezone: string;
1409
976
  };
1410
- /** What reaches a worker: an answer to its question, or more instructions. */
1411
- interface FoundryDelegationReply {
1412
- readonly kind: "reply";
1413
- readonly delegationId: string;
1414
- /** Route of the delegating definition. */
1415
- readonly from: string;
1416
- readonly message: string;
1417
- }
1418
- /**
1419
- * An inbound transmission event for a conversation that already has a run:
1420
- * it joins that run's turn, or waits for the conversation, instead of
1421
- * starting a second run beside it.
1422
- */
1423
- interface FoundryTransmissionDelivery {
1424
- readonly kind: "transmission";
1425
- /** The pending-inbound record that keeps this event until a run finishes with it. */
1426
- readonly pendingId: string;
1427
- readonly routeId: string;
1428
- readonly eventId: string;
1429
- /** The event as the run reads it: the serialized `<transmission>`, or the transmission's own rendering. */
977
+ interface DefineFoundryScheduleOptions {
978
+ /** Stable semantic name within one agent definition. It is not a runtime id. */
979
+ readonly name: string;
980
+ readonly description?: string;
1430
981
  readonly message: string;
982
+ readonly payload?: unknown;
983
+ readonly timing: FoundryScheduleTimingInput;
984
+ readonly enabled?: boolean;
1431
985
  }
1432
- interface DelegationCommandBase {
1433
- readonly id: string;
1434
- readonly definitionId: string;
1435
- readonly agentId: string;
1436
- readonly conversationId: string;
1437
- readonly workspaceId: string;
1438
- readonly delegationId: string;
1439
- }
1440
- type FoundryDelegationCommand = (DelegationCommandBase & {
1441
- readonly type: "delegate";
1442
- readonly to: string;
1443
- readonly task: string;
1444
- }) | (DelegationCommandBase & {
1445
- readonly type: "delegate.reply";
1446
- readonly message: string;
1447
- }) | (DelegationCommandBase & {
1448
- readonly type: "delegate.ask";
1449
- readonly question: string;
1450
- });
986
+ type FoundryScheduleDefinition = Readonly<DefineFoundryScheduleOptions> & {
987
+ readonly [FOUNDRY_SCHEDULE_BRAND]: true;
988
+ };
989
+ declare function defineSchedule(options: DefineFoundryScheduleOptions): FoundryScheduleDefinition;
990
+ declare function isFoundrySchedule(value: unknown): value is FoundryScheduleDefinition;
1451
991
 
1452
992
  declare const FOUNDRY_CORE_COMMAND_EVENT = "foundry.core.command";
1453
993
  type FoundryCoreCommand = {
@@ -1571,7 +1111,7 @@ type FoundryCoreCommand = {
1571
1111
  readonly observability?: unknown;
1572
1112
  readonly applicationId?: string;
1573
1113
  readonly transmissionId?: string;
1574
- } | FoundryDelegationCommand;
1114
+ } | FoundryDelegationCommand | DurableMessageCommand;
1575
1115
  /** Resolve an installed app's generated outbound tool without duplicating ids. */
1576
1116
  declare function installedApplicationTransmissionToolName(application: {
1577
1117
  readonly id: string;
@@ -1680,6 +1220,8 @@ interface AgentAssemblyContext<TInput = unknown> {
1680
1220
  readonly message: Message;
1681
1221
  /** Exact input that will be passed to `Glove.processRequest`. */
1682
1222
  readonly messageInput: FoundryMessageInput;
1223
+ /** Spontaneous events that started this run. Custom handlers acknowledge them on successful return. */
1224
+ readonly events?: ReadonlyArray<glove_core.AgentEvent>;
1683
1225
  /** Convenience text projection matching Glove's multimodal normalization. */
1684
1226
  readonly messageText: string;
1685
1227
  /** Persisted native Glove messages before the current inbound turn. */
@@ -1712,6 +1254,8 @@ type FoundryCall<TInputSchema extends z.ZodType = z.ZodType, TOutputSchema exten
1712
1254
  declare function defineCall<TInputSchema extends z.ZodType, TOutputSchema extends z.ZodType>(options: FoundryCallOptions<TInputSchema, TOutputSchema>): FoundryCall<TInputSchema, TOutputSchema>;
1713
1255
  interface FoundryExecutionContext<TInput = unknown> extends FoundrySurfaceContext<TInput>, FoundryGuidanceHandles {
1714
1256
  readonly installations: ReadonlyArray<AgentInstallation>;
1257
+ readonly events?: ReadonlyArray<glove_core.AgentEvent>;
1258
+ readonly delegations?: ReadonlyArray<FoundryDelegation>;
1715
1259
  /** Register run-scoped teardown for an explicitly mounted capability. Runs in reverse order, even if assembly fails. */
1716
1260
  readonly onCleanup: (cleanup: () => void | Promise<void>) => void;
1717
1261
  /** Native persistent environment mounted for this run, when configured. */
@@ -1744,6 +1288,10 @@ interface AgentAssemblyOptions<TInput = unknown> {
1744
1288
  readonly systemPrompt?: FoundryResolver<string, TInput>;
1745
1289
  readonly displayManager?: FoundryResolver<DisplayManagerAdapter, TInput>;
1746
1290
  readonly serverMode?: boolean;
1291
+ /** Maximum wall time for one run; independent workers can allow hours. */
1292
+ readonly runTimeoutMs?: number;
1293
+ /** Limit concurrent runs of this definition to leave capacity for other agents. */
1294
+ readonly maxConcurrentRuns?: number;
1747
1295
  readonly maxRetries?: number;
1748
1296
  readonly maxConsecutiveErrors?: number;
1749
1297
  readonly compactionLimit?: FoundryResolver<number, TInput>;
@@ -1761,6 +1309,8 @@ interface AgentAssemblyOptions<TInput = unknown> {
1761
1309
  * needs answered, comes back to this conversation.
1762
1310
  */
1763
1311
  readonly delegates?: FoundryListResolver<FoundryDelegate, TInput>;
1312
+ readonly durableSubagents?: DurableSubagents;
1313
+ readonly eventDelivery?: FoundryEventPolicy;
1764
1314
  /**
1765
1315
  * When this agent works on a delegated task, how long glove_foundry_ask
1766
1316
  * waits in the same run for an answer before the run suspends. Default 90s.
@@ -1803,6 +1353,8 @@ interface AgentAssemblyOptions<TInput = unknown> {
1803
1353
  readonly handler?: (context: AgentHandlerContext<TInput>) => Resolvable<unknown>;
1804
1354
  }
1805
1355
  interface FoundryMeshConfig {
1356
+ readonly delivery?: "events" | "inbox";
1357
+ readonly whenIdle?: "wake" | "defer" | "auto";
1806
1358
  readonly adapter: MeshAdapter;
1807
1359
  readonly identity?: Omit<AgentIdentity, "id"> & {
1808
1360
  readonly id?: string;
@@ -1846,6 +1398,10 @@ interface FoundryAgentConventionModule {
1846
1398
  readonly systemPrompt?: AgentAssemblyOptions["systemPrompt"];
1847
1399
  readonly displayManager?: AgentAssemblyOptions["displayManager"];
1848
1400
  readonly serverMode?: boolean;
1401
+ /** Maximum wall time for one run; independent workers can allow hours. */
1402
+ readonly runTimeoutMs?: number;
1403
+ /** Limit concurrent runs of this definition to leave capacity for other agents. */
1404
+ readonly maxConcurrentRuns?: number;
1849
1405
  readonly maxRetries?: number;
1850
1406
  readonly maxConsecutiveErrors?: number;
1851
1407
  readonly compactionLimit?: AgentAssemblyOptions["compactionLimit"];
@@ -1857,6 +1413,8 @@ interface FoundryAgentConventionModule {
1857
1413
  readonly skills?: AgentAssemblyOptions["skills"];
1858
1414
  readonly subagents?: AgentAssemblyOptions["subagents"];
1859
1415
  readonly delegates?: AgentAssemblyOptions["delegates"];
1416
+ readonly durableSubagents?: DurableSubagents;
1417
+ readonly eventDelivery?: FoundryEventPolicy;
1860
1418
  readonly answerWaitMs?: number;
1861
1419
  readonly memory?: AgentAssemblyOptions["memory"];
1862
1420
  readonly goals?: AgentAssemblyOptions["goals"];
@@ -1925,4 +1483,587 @@ declare function defineSubagent(options: DefineFoundrySubagentOptions): DefineSu
1925
1483
  type FoundryRouteMap = Record<string, object>;
1926
1484
  declare function defineRoutes<const TRoutes extends FoundryRouteMap>(routes: TRoutes): TRoutes;
1927
1485
 
1928
- export { type ComposedAgentPlaybook as $, type AgentHandlerContext as A, type AgentAssemblyOptions as B, type Conversation as C, AgentDefinitionId as D, type EnvironmentValue as E, type FoundryDelegationUpdate as F, type AgentDefinitionSurfaceContext as G, type AgentFactoryContext as H, type InboundDeliveryClaim as I, AgentId as J, type AgentInstallContext as K, type AgentInstallation as L, type AgentInstallationKind as M, type AgentPlaybookInput as N, OutboundRoute as O, type PlaybookSubscription as P, type AgentProvisioningPolicy as Q, type AgentRuntimeControls as R, type SharedInboxItem as S, type AnyFoundryAgent as T, type ApplicationConnectionContext as U, type ApplicationConnectionState as V, type WorkspaceEntry as W, type ApplicationConnectionStatus as X, BindingId as Y, BindingNotFound as Z, CapabilityId as _, type FoundryDataAdapter as a, type FoundryCoreCommand as a$, type ComposedAgentPlaybookInput as a0, type ConnectionReceiveInput as a1, type CreateAgentInstanceOptions as a2, type CreateConversationOptions as a3, type CustomProvisionedAgent as a4, type CustomProvisioningContext as a5, type DefineAgentOptions as a6, type DefineConnectionOptions as a7, type DefineFoundryReplOptions as a8, type DefineFoundryScheduleOptions as a9, FOUNDRY_PLAYBOOK_ACTION_BRAND as aA, FOUNDRY_REPL_BRAND as aB, FOUNDRY_SCHEDULE_BRAND as aC, FOUNDRY_SHARED_TOOL_BRAND as aD, FOUNDRY_SUBSCRIBER_BRAND as aE, FOUNDRY_TRANSMISSION_BRAND as aF, FOUNDRY_TRANSMISSION_EVENT_BRAND as aG, FOUNDRY_TRANSMISSION_PREDICATE_BRAND as aH, FOUNDRY_WORKING_ENVIRONMENT_BRAND as aI, type FoundryAccountSessionAdapter as aJ, type FoundryAgent as aK, type FoundryAgentComponent as aL, type FoundryAgentComposition as aM, type FoundryAgentConventionModule as aN, type FoundryAgentDefinition as aO, type FoundryAgentMode as aP, type FoundryApp as aQ, type FoundryApplicationConnection as aR, type FoundryCall as aS, type FoundryCallContext as aT, type FoundryCallOptions as aU, type FoundryCapabilityKind as aV, type FoundryCapabilityManifest as aW, type FoundryCapabilityManifestEntry as aX, type FoundryCapabilityRegistry as aY, type FoundryCompositionSource as aZ, type FoundryContextProvider as a_, type DefineFoundrySubagentOptions as aa, type DefineFoundryWorkingEnvironmentOptions as ab, type DefinePlaybookSubscriptionOptions as ac, type DefinitionConfigInput as ad, EMPTY_AGENT_COMPOSITION as ae, EMPTY_CAPABILITY_REGISTRY as af, EMPTY_NATIVE_REGISTRY as ag, type EgressAdapter as ah, type EgressContext as ai, EventId as aj, EventNotFound as ak, EventReference as al, FOUNDRY_AGENT_APPLICATION_BRAND as am, FOUNDRY_AGENT_BRAND as an, FOUNDRY_AGENT_DEFINITION_BRAND as ao, FOUNDRY_AGENT_FILE_ENV as ap, FOUNDRY_AGENT_ROUTE_ENV as aq, FOUNDRY_APPLICATION_ENV as ar, FOUNDRY_COMPOSED_PLAYBOOK_BRAND as as, FOUNDRY_CONNECTION_BRAND as at, FOUNDRY_CORE_COMMAND_EVENT as au, FOUNDRY_EVENT_PREFIX as av, FOUNDRY_EXECUTION_MARKER as aw, FOUNDRY_LAYER_BRAND as ax, FOUNDRY_MCP_BRAND as ay, FOUNDRY_MEMORY_BRAND as az, type AgentInstance as b, type FoundryWorkingEnvironmentDefinition as b$, type FoundryDelegate as b0, type FoundryDelegateOptions as b1, type FoundryDelegation as b2, type FoundryDelegationReply as b3, type FoundryDelegationStatus as b4, type FoundryDomainError as b5, type FoundryExecutionContext as b6, type FoundryFactsOptions as b7, type FoundryFormsOptions as b8, type FoundryGoalsOptions as b9, type FoundryProgrammaticToolSelection as bA, type FoundryProgrammaticTools as bB, type FoundryPythonReplDefinition as bC, type FoundryReplDefinition as bD, type FoundryRequest as bE, type FoundryResolvedMcp as bF, type FoundryResolver as bG, type FoundryResult as bH, type FoundryRouteMap as bI, type FoundryScheduleDefinition as bJ, type FoundryScheduleTiming as bK, type FoundryScheduleTimingInput as bL, type FoundrySharedTool as bM, type FoundrySubagentToolContext as bN, type FoundrySubscriber as bO, type FoundrySubscriberOptions as bP, type FoundrySubscriberSelection as bQ, type FoundrySurfaceContext as bR, type FoundrySuspension as bS, type FoundryToolBody as bT, type FoundryTransmission as bU, type FoundryTransmissionDelivery as bV, type FoundryTransmissionEvent as bW, type FoundryTransmissionPredicate as bX, type FoundryVfs as bY, type FoundryVfsHandle as bZ, type FoundryWorkingEnvironmentCreateContext as b_, type FoundryGuidanceHandles as ba, type FoundryGuidanceScope as bb, type FoundryHookDefinition as bc, type FoundryInstallable as bd, type FoundryInstanceProvisioner as be, type FoundryJavaScriptReplDefinition as bf, type FoundryLayer as bg, type FoundryLayerOptions as bh, type FoundryLayerReference as bi, type FoundryLayerSelection as bj, type FoundryLispReplDefinition as bk, type FoundryListResolver as bl, type FoundryMcp as bm, type FoundryMcpOptions as bn, type FoundryMemoryProfile as bo, type FoundryMemoryProfileOptions as bp, type FoundryMemoryReference as bq, type FoundryMemorySelection as br, type FoundryMeshConfig as bs, type FoundryMessageInput as bt, type FoundryMountedRepl as bu, type FoundryNativeManifest as bv, type FoundryNativeManifestEntry as bw, type FoundryNativeRegistry as bx, type FoundryPlaybookAction as by, type FoundryProgrammaticToolContext as bz, type FoundryActivationRecord as c, defineRepl as c$, type FoundryWorkingEnvironmentPersistenceAdapter as c0, type FoundryWorkingEnvironmentPersistenceContext as c1, GrantResolutionError as c2, type InboundContract as c3, type InferAgentInput as c4, type InferAgentOutput as c5, type InferInboundEvent as c6, type InferOutboundInput as c7, type InferOutboundOutput as c8, type IngressAdapter as c9, type TransmissionPredicateOptions as cA, type TransmissionSerializationContext as cB, type UpdateAgentInstanceOptions as cC, type UpdateConversationOptions as cD, composeAgent as cE, composePlaybook as cF, configureLayer as cG, configureMemory as cH, createAgentInstance as cI, createConversation as cJ, createFoundryCoreTools as cK, createInstalledApplicationTransmissionTools as cL, defineAgent as cM, defineAgentApplication as cN, defineAgentFromModule as cO, defineAgentInstance as cP, defineApp as cQ, defineCall as cR, defineConnection as cS, defineFacts as cT, defineForms as cU, defineGoals as cV, defineLayer as cW, defineMcp as cX, defineMemory as cY, definePlaybookAction as cZ, definePlaybookSubscription as c_, type IngressContext as ca, type InstallationSelection as cb, type McpAdapterFactory as cc, MemoryFoundryDataAdapter as cd, type OutboundContract as ce, type PlaybookActionOptions as cf, type PlaybookDirective as cg, type PlaybookDirectiveInput as ch, type PlaybookMatch as ci, type PlaybookMatchInput as cj, type PlaybookOutboundDirective as ck, type PlaybookOutboundInput as cl, type PlaybookSubscriptionTarget as cm, type PlaybookSubscriptionTargetInput as cn, ReplyPolicy as co, Route as cp, RouteId as cq, RouteNotFound as cr, RunGrant as cs, RunId as ct, type SharedToolOptions as cu, TopologyConflict as cv, type TransmissionEventDirection as cw, type TransmissionEventOptions as cx, TransmissionId as cy, type TransmissionOptions as cz, type ProvisionAgentOptions as d, defineRoutes as d0, defineSchedule as d1, defineSharedTool as d2, defineSubagent as d3, defineSubscriber as d4, defineTransmission as d5, defineTransmissionEvent as d6, defineTransmissionPredicate as d7, defineWorkingEnvironment as d8, foundryDataEnvironmentPersistence as d9, foundryGuidanceSubject as da, install as db, installRegistry as dc, installationKey as dd, installedApplicationTransmissionToolName as de, internalAgentName as df, isFoundryAgent as dg, isFoundryAgentDefinition as dh, isFoundryCapability as di, isFoundryLayer as dj, isFoundrySchedule as dk, isFoundrySubscriber as dl, isFoundryTransmission as dm, isInboxCapableStore as dn, mountAgentDefinitionMemory as dp, mountFoundrySurfaces as dq, reconstructAgentInstance as dr, reconstructPlaybook as ds, reconstructPlaybookSubscription as dt, routeFromInternalAgentName as du, toGloveMessage as dv, toGloveRequestInput as dw, transmissionPredicate as dx, type FoundryPendingInbound as e, type FoundryWorkingEnvironmentSnapshotOwner as f, type FoundryTask as g, type AgentPlaybook as h, type AnyFoundryTransmission as i, AccountReference as j, type InferAccountMetadata as k, AgentBinding as l, type FoundryAgentApplication as m, InboundRoute as n, type CapabilityDefinition as o, type InferInboundConfig as p, type InferOutboundConfig as q, type AccountContract as r, AccountId as s, AccountNotFound as t, AccountSessionUnavailable as u, AccountSummary as v, type AgentApplicationContribution as w, type AgentApplicationInstallContext as x, type AgentApplicationOptions as y, type AgentAssemblyContext as z };
1486
+ interface DurableSubagentOptions {
1487
+ readonly agent: FoundryAgentDefinition;
1488
+ readonly description?: string;
1489
+ readonly eventDelivery?: FoundryEventPolicy;
1490
+ readonly inherit?: {
1491
+ /** A snapshot at provisioning. Transcripts are never inherited. */
1492
+ readonly context?: boolean;
1493
+ readonly tools?: ReadonlyArray<string>;
1494
+ /** Shared memory is read-only unless curator access is explicitly requested. */
1495
+ readonly memory?: "isolated" | "shared" | {
1496
+ readonly scope: "isolated" | "shared";
1497
+ readonly access?: "reader" | "curator";
1498
+ readonly profiles?: ReadonlyArray<string>;
1499
+ };
1500
+ /** Only currently installed parent apps are inherited. Restrictions can only narrow access. */
1501
+ readonly apps?: ReadonlyArray<string | FoundryApp>;
1502
+ };
1503
+ /** Delete application-owned private memory/transcripts/files before purging Foundry records. Must be idempotent. */
1504
+ readonly cleanup?: (input: {
1505
+ readonly agent: AgentInstance;
1506
+ readonly conversationIds: ReadonlyArray<string>;
1507
+ }) => void | Promise<void>;
1508
+ }
1509
+ type DurableSubagents = Readonly<Record<string, DurableSubagentOptions>>;
1510
+ interface DurableSubagentOwnership {
1511
+ readonly parentAgentId: string;
1512
+ readonly name: string;
1513
+ readonly status: "active" | "archived" | "purged";
1514
+ }
1515
+ interface AgentMessageReceipt {
1516
+ readonly messageId: string;
1517
+ readonly agentId: string;
1518
+ readonly conversationId: string;
1519
+ readonly runId?: string;
1520
+ }
1521
+ interface DurableMessageCommand {
1522
+ readonly type: "agent.message";
1523
+ readonly id: string;
1524
+ readonly definitionId: string;
1525
+ readonly agentId: string;
1526
+ readonly conversationId: string;
1527
+ readonly workspaceId: string;
1528
+ readonly to: string;
1529
+ readonly message: string;
1530
+ readonly delivery?: FoundryMessageOptions;
1531
+ }
1532
+
1533
+ type AgentProvisioningPolicy = {
1534
+ readonly mode: "singleton";
1535
+ readonly key?: string;
1536
+ } | {
1537
+ readonly mode: "per-thread";
1538
+ } | {
1539
+ readonly mode: "per-event";
1540
+ } | {
1541
+ readonly mode: "existing";
1542
+ readonly agentIds: ReadonlyArray<string>;
1543
+ } | {
1544
+ readonly mode: "custom";
1545
+ readonly adapter: string;
1546
+ };
1547
+ interface PlaybookSubscriptionTarget {
1548
+ readonly definitionId: string;
1549
+ readonly provisioning: AgentProvisioningPolicy;
1550
+ readonly context: Readonly<Record<string, unknown>>;
1551
+ readonly installations: ReadonlyArray<AgentInstallation>;
1552
+ }
1553
+ interface PlaybookSubscription {
1554
+ readonly id: string;
1555
+ readonly workspaceId: string;
1556
+ readonly enabled: boolean;
1557
+ readonly playbook: AgentPlaybook;
1558
+ readonly targets: ReadonlyArray<PlaybookSubscriptionTarget>;
1559
+ readonly createdAt: string;
1560
+ readonly updatedAt: string;
1561
+ }
1562
+ interface PlaybookSubscriptionTargetInput {
1563
+ readonly agent: FoundryAgentDefinition;
1564
+ readonly provisioning?: AgentProvisioningPolicy;
1565
+ readonly context?: Readonly<Record<string, unknown>>;
1566
+ readonly installations?: ReadonlyArray<AgentInstallation>;
1567
+ }
1568
+ interface DefinePlaybookSubscriptionOptions {
1569
+ /** @deprecated File-routed subscriptions derive identity from their filename. */
1570
+ readonly id?: string;
1571
+ readonly workspaceId?: string;
1572
+ readonly enabled?: boolean;
1573
+ readonly playbook: AgentPlaybookInput | AgentPlaybook;
1574
+ readonly targets: ReadonlyArray<PlaybookSubscriptionTargetInput>;
1575
+ readonly createdAt?: string;
1576
+ readonly updatedAt?: string;
1577
+ }
1578
+ interface CustomProvisioningContext {
1579
+ readonly subscription: PlaybookSubscription;
1580
+ readonly target: PlaybookSubscriptionTarget;
1581
+ readonly route: InboundRoute;
1582
+ readonly eventId: string;
1583
+ readonly eventName: string;
1584
+ readonly threadKey: string;
1585
+ readonly event: unknown;
1586
+ }
1587
+ interface CustomProvisionedAgent extends CreateAgentInstanceOptions {
1588
+ /** Stable uniqueness key; the data adapter enforces it atomically. */
1589
+ readonly provisioningKey: string;
1590
+ }
1591
+ interface FoundryInstanceProvisioner {
1592
+ readonly identifier: string;
1593
+ provision(adapter: string, context: CustomProvisioningContext): Effect.Effect<ReadonlyArray<CustomProvisionedAgent>, unknown, never>;
1594
+ }
1595
+ declare function definePlaybookSubscription(options: DefinePlaybookSubscriptionOptions): PlaybookSubscription;
1596
+ /** Rehydrate the value-only representation returned by a durable adapter. */
1597
+ declare function reconstructPlaybookSubscription(subscription: PlaybookSubscription): PlaybookSubscription;
1598
+
1599
+ interface AgentInstance {
1600
+ readonly durableSubagent?: DurableSubagentOwnership;
1601
+ readonly id: string;
1602
+ readonly definitionId: string;
1603
+ readonly workspaceId: string;
1604
+ /** Stable adapter-enforced key used by lazy subscription provisioning. */
1605
+ readonly provisioningKey?: string;
1606
+ readonly context: Readonly<Record<string, unknown>>;
1607
+ /** Persisted desired state. Definitions only provide the capability catalogue. */
1608
+ readonly installations: ReadonlyArray<AgentInstallation>;
1609
+ readonly playbooks: ReadonlyArray<AgentPlaybook>;
1610
+ readonly createdAt: string;
1611
+ readonly updatedAt: string;
1612
+ }
1613
+ interface Conversation {
1614
+ readonly id: string;
1615
+ readonly agentId: string;
1616
+ readonly workspaceId: string;
1617
+ readonly title?: string;
1618
+ readonly context: Readonly<Record<string, unknown>>;
1619
+ readonly createdAt: string;
1620
+ readonly updatedAt: string;
1621
+ }
1622
+ interface WorkspaceEntry {
1623
+ readonly workspaceId: string;
1624
+ readonly key: string;
1625
+ readonly value: unknown;
1626
+ readonly updatedAt: string;
1627
+ }
1628
+ interface SharedInboxItem {
1629
+ readonly id: string;
1630
+ readonly workspaceId: string;
1631
+ readonly conversationId?: string;
1632
+ readonly agentId?: string;
1633
+ readonly topic: string;
1634
+ readonly payload: unknown;
1635
+ readonly status: "pending" | "resolved" | "dismissed";
1636
+ readonly createdAt: string;
1637
+ readonly updatedAt: string;
1638
+ }
1639
+ interface EnvironmentValue {
1640
+ readonly key: string;
1641
+ /** Secret values are deliberately never exposed through this primitive. */
1642
+ readonly value: unknown;
1643
+ readonly scope: "workspace" | "agent" | "conversation";
1644
+ readonly workspaceId: string;
1645
+ readonly agentId?: string;
1646
+ readonly conversationId?: string;
1647
+ }
1648
+ interface FoundryTask {
1649
+ readonly id: string;
1650
+ readonly workspaceId: string;
1651
+ readonly agentId?: string;
1652
+ readonly conversationId?: string;
1653
+ readonly title: string;
1654
+ readonly detail?: string;
1655
+ readonly status: "open" | "in-progress" | "completed" | "cancelled";
1656
+ readonly createdAt: string;
1657
+ readonly updatedAt: string;
1658
+ }
1659
+ interface InboundDeliveryClaim {
1660
+ readonly key: string;
1661
+ readonly status: "pending" | "completed";
1662
+ readonly runIds: ReadonlyArray<string>;
1663
+ readonly claimedAt: string;
1664
+ readonly completedAt?: string;
1665
+ }
1666
+ /**
1667
+ * An inbound event handed to one agent and not yet finished with: kept from
1668
+ * dispatch until the run that handles it settles, so a restart delivers it
1669
+ * again instead of losing it with the in-memory run queue.
1670
+ */
1671
+ interface FoundryPendingInbound {
1672
+ /** `<routeId>:<eventId>:<agentId>`. */
1673
+ readonly id: string;
1674
+ readonly definitionId: string;
1675
+ /** The request a run for this event starts from. */
1676
+ readonly request: FoundryRequest;
1677
+ /** The run handling it now; absent while the event waits for its conversation. */
1678
+ readonly runId?: string;
1679
+ readonly createdAt: string;
1680
+ }
1681
+ interface FoundryWorkingEnvironmentSnapshotOwner {
1682
+ readonly scope: "agent" | "conversation";
1683
+ readonly definitionId: string;
1684
+ readonly agentId: string;
1685
+ readonly conversationId: string;
1686
+ readonly workspaceId: string;
1687
+ }
1688
+ /**
1689
+ * Adapter-backed runtime data created by Foundry's scheduling and sleep tools.
1690
+ * This is reconstructed state, never a file-authored definition primitive.
1691
+ */
1692
+ interface FoundryActivationRecord {
1693
+ readonly id: string;
1694
+ readonly kind: "scheduled" | "sleep";
1695
+ readonly definitionId: string;
1696
+ readonly agentId: string;
1697
+ readonly conversationId: string;
1698
+ readonly workspaceId: string;
1699
+ readonly message: string;
1700
+ readonly payload?: unknown;
1701
+ readonly timing: FoundryScheduleTiming;
1702
+ readonly origin: "agent-definition" | "agent-tool";
1703
+ readonly scheduleName?: string;
1704
+ /** Hash of the last reconciled definition value; runtime edits remain overrides. */
1705
+ readonly definitionRevision?: string;
1706
+ readonly status: "pending" | "active" | "paused" | "completed" | "cancelled";
1707
+ readonly createdByRunId: string;
1708
+ readonly lastRunId?: string;
1709
+ readonly createdAt: string;
1710
+ readonly updatedAt: string;
1711
+ }
1712
+ interface FoundryDataAdapter {
1713
+ /** Atomic insert-if-absent, scoped by eventRecordId. Required for durable event delivery. */
1714
+ claimEvent?(record: FoundryEventRecord): Effect.Effect<boolean, unknown, never>;
1715
+ putEvent?(record: FoundryEventRecord): Effect.Effect<void, unknown, never>;
1716
+ listEvents?(): Effect.Effect<ReadonlyArray<FoundryEventRecord>, unknown, never>;
1717
+ readonly identifier: string;
1718
+ /** Purge an archived worker's owned records, retaining an identity tombstone. Shared workspace data is untouched. */
1719
+ purgeAgentData?(agentId: string): Effect.Effect<void, unknown, never>;
1720
+ getAgent(id: string): Effect.Effect<AgentInstance | null, unknown, never>;
1721
+ putAgent(agent: AgentInstance): Effect.Effect<void, unknown, never>;
1722
+ listAgents(definitionId?: string): Effect.Effect<ReadonlyArray<AgentInstance>, unknown, never>;
1723
+ provisionAgent(input: ProvisionAgentOptions): Effect.Effect<AgentInstance, unknown, never>;
1724
+ getPlaybookSubscription(id: string): Effect.Effect<PlaybookSubscription | null, unknown, never>;
1725
+ putPlaybookSubscription(subscription: PlaybookSubscription): Effect.Effect<void, unknown, never>;
1726
+ deletePlaybookSubscription(id: string): Effect.Effect<boolean, unknown, never>;
1727
+ listPlaybookSubscriptions(workspaceId?: string): Effect.Effect<ReadonlyArray<PlaybookSubscription>, unknown, never>;
1728
+ getInboundDelivery(key: string): Effect.Effect<InboundDeliveryClaim | null, unknown, never>;
1729
+ claimInboundDelivery(key: string): Effect.Effect<boolean, unknown, never>;
1730
+ completeInboundDelivery(key: string, runIds: ReadonlyArray<string>): Effect.Effect<void, unknown, never>;
1731
+ releaseInboundDelivery(key: string): Effect.Effect<void, unknown, never>;
1732
+ /**
1733
+ * Pending inbound events (optional). With these, an inbound event survives
1734
+ * a restart until the run that handles it finishes; without them, an event
1735
+ * whose run was still queued or running when the process stopped is lost.
1736
+ */
1737
+ putPendingInbound?(record: FoundryPendingInbound): Effect.Effect<void, unknown, never>;
1738
+ deletePendingInbound?(id: string): Effect.Effect<void, unknown, never>;
1739
+ listPendingInbound?(): Effect.Effect<ReadonlyArray<FoundryPendingInbound>, unknown, never>;
1740
+ getActivation(id: string): Effect.Effect<FoundryActivationRecord | null, unknown, never>;
1741
+ putActivation(activation: FoundryActivationRecord): Effect.Effect<void, unknown, never>;
1742
+ listActivations(workspaceId?: string): Effect.Effect<ReadonlyArray<FoundryActivationRecord>, unknown, never>;
1743
+ getConversation(id: string): Effect.Effect<Conversation | null, unknown, never>;
1744
+ putConversation(conversation: Conversation): Effect.Effect<void, unknown, never>;
1745
+ listConversations(agentId: string): Effect.Effect<ReadonlyArray<Conversation>, unknown, never>;
1746
+ getWorkspaceEntry(workspaceId: string, key: string): Effect.Effect<WorkspaceEntry | null, unknown, never>;
1747
+ putWorkspaceEntry(entry: WorkspaceEntry): Effect.Effect<void, unknown, never>;
1748
+ /** Atomic optimistic update. null requires absence; updates must advance updatedAt. */
1749
+ compareAndSetWorkspaceEntry?(entry: WorkspaceEntry, expectedUpdatedAt: string | null): Effect.Effect<boolean, unknown, never>;
1750
+ listWorkspaceEntries(workspaceId: string): Effect.Effect<ReadonlyArray<WorkspaceEntry>, unknown, never>;
1751
+ /** Private VFS persistence; snapshots are never exposed as workspace entries. */
1752
+ getWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner): Effect.Effect<EnvSnapshot | null, unknown, never>;
1753
+ putWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner, snapshot: EnvSnapshot): Effect.Effect<void, unknown, never>;
1754
+ putInboxItem(item: SharedInboxItem): Effect.Effect<void, unknown, never>;
1755
+ listInboxItems(workspaceId: string): Effect.Effect<ReadonlyArray<SharedInboxItem>, unknown, never>;
1756
+ putTask(task: FoundryTask): Effect.Effect<void, unknown, never>;
1757
+ listTasks(workspaceId: string): Effect.Effect<ReadonlyArray<FoundryTask>, unknown, never>;
1758
+ listEnvironment(scope: {
1759
+ readonly workspaceId: string;
1760
+ readonly agentId?: string;
1761
+ readonly conversationId?: string;
1762
+ }): Effect.Effect<ReadonlyArray<EnvironmentValue>, unknown, never>;
1763
+ }
1764
+ /** The exact request shape accepted by `Glove.processRequest`. */
1765
+ type FoundryMessageInput = string | ReadonlyArray<ContentPart>;
1766
+ interface FoundryRequest {
1767
+ readonly agentId: string;
1768
+ readonly conversationId: string;
1769
+ readonly workspaceId: string;
1770
+ readonly message: FoundryMessageInput;
1771
+ readonly payload?: unknown;
1772
+ readonly context?: Readonly<Record<string, unknown>>;
1773
+ readonly source?: {
1774
+ readonly kind: "direct" | "transmission" | "activation" | "spawn" | "background" | "delegation" | "agent-message";
1775
+ readonly id?: string;
1776
+ readonly provider?: string;
1777
+ readonly eventId?: string;
1778
+ readonly threadKey?: string;
1779
+ };
1780
+ }
1781
+ /**
1782
+ * Normalize Foundry's wire input into the native user `Message` seen by the
1783
+ * Glove loop. Lazy assembly happens before hooks run, so this intentionally
1784
+ * represents the unmodified inbound turn.
1785
+ */
1786
+ declare function toGloveMessage(input: FoundryMessageInput): Message;
1787
+ /** Clone readonly request parts for Glove's mutable public input signature. */
1788
+ declare function toGloveRequestInput(input: FoundryMessageInput): string | ContentPart[];
1789
+ interface FoundryResult {
1790
+ /** Internal event receipts, acknowledged by the controller only after successful completion. */
1791
+ readonly consumedEventIds?: ReadonlyArray<string>;
1792
+ readonly status: "completed" | "suspended";
1793
+ readonly value: unknown;
1794
+ readonly agentId: string;
1795
+ readonly conversationId: string;
1796
+ readonly workspaceId: string;
1797
+ readonly suspension?: FoundrySuspension;
1798
+ }
1799
+ /** Why a run ended without finishing: it went to sleep, or it asked a question. */
1800
+ type FoundrySuspension = {
1801
+ readonly kind?: "sleep";
1802
+ readonly commandId: string;
1803
+ readonly wakeAt: string;
1804
+ } | {
1805
+ readonly kind: "question";
1806
+ readonly commandId: string;
1807
+ readonly delegationId: string;
1808
+ readonly question: string;
1809
+ };
1810
+ interface CreateAgentInstanceOptions {
1811
+ /** @internal Set only by durable worker provisioning. */
1812
+ readonly durableSubagent?: DurableSubagentOwnership;
1813
+ readonly id?: string;
1814
+ readonly workspaceId?: string;
1815
+ readonly context?: Readonly<Record<string, unknown>>;
1816
+ readonly installations?: ReadonlyArray<AgentInstallation>;
1817
+ readonly playbooks?: ReadonlyArray<AgentPlaybook>;
1818
+ }
1819
+ interface ProvisionAgentOptions extends CreateAgentInstanceOptions {
1820
+ readonly definitionId: string;
1821
+ readonly provisioningKey: string;
1822
+ }
1823
+ interface UpdateAgentInstanceOptions {
1824
+ readonly context?: Readonly<Record<string, unknown>>;
1825
+ readonly installations?: ReadonlyArray<AgentInstallation>;
1826
+ readonly playbooks?: ReadonlyArray<AgentPlaybook>;
1827
+ }
1828
+ interface CreateConversationOptions {
1829
+ readonly id?: string;
1830
+ readonly workspaceId?: string;
1831
+ readonly title?: string;
1832
+ readonly context?: Readonly<Record<string, unknown>>;
1833
+ }
1834
+ interface UpdateConversationOptions {
1835
+ readonly title?: string;
1836
+ readonly context?: Readonly<Record<string, unknown>>;
1837
+ }
1838
+ declare class MemoryFoundryDataAdapter implements FoundryDataAdapter {
1839
+ readonly identifier: string;
1840
+ private readonly agents;
1841
+ private readonly agentsByProvisioningKey;
1842
+ private readonly subscriptions;
1843
+ private readonly inboundDeliveries;
1844
+ private readonly events;
1845
+ private readonly pendingInbound;
1846
+ private readonly activations;
1847
+ private readonly conversations;
1848
+ private readonly workspace;
1849
+ private readonly workingEnvironments;
1850
+ private readonly inbox;
1851
+ private readonly tasks;
1852
+ private readonly environment;
1853
+ private pendingAgents;
1854
+ private pendingSubscriptions;
1855
+ constructor(options?: {
1856
+ readonly identifier?: string;
1857
+ readonly environment?: ReadonlyArray<EnvironmentValue>;
1858
+ readonly agents?: ReadonlyArray<AgentInstance>;
1859
+ readonly conversations?: ReadonlyArray<Conversation>;
1860
+ readonly subscriptions?: ReadonlyArray<PlaybookSubscription>;
1861
+ readonly activations?: ReadonlyArray<FoundryActivationRecord>;
1862
+ });
1863
+ /** Resolve file-owned identities only after Foundry discovery has bound them. */
1864
+ private materializeSeeds;
1865
+ getAgent(id: string): Effect.Effect<AgentInstance | null, never, never>;
1866
+ putAgent(agent: AgentInstance): Effect.Effect<void, never, never>;
1867
+ listAgents(definitionId?: string): Effect.Effect<AgentInstance[], never, never>;
1868
+ provisionAgent(input: ProvisionAgentOptions): Effect.Effect<AgentInstance, never, never>;
1869
+ purgeAgentData(agentId: string): Effect.Effect<void, never, never>;
1870
+ getPlaybookSubscription(id: string): Effect.Effect<PlaybookSubscription | null, never, never>;
1871
+ putPlaybookSubscription(subscription: PlaybookSubscription): Effect.Effect<void, never, never>;
1872
+ deletePlaybookSubscription(id: string): Effect.Effect<boolean, never, never>;
1873
+ listPlaybookSubscriptions(workspaceId?: string): Effect.Effect<PlaybookSubscription[], never, never>;
1874
+ getInboundDelivery(key: string): Effect.Effect<InboundDeliveryClaim | null, never, never>;
1875
+ claimInboundDelivery(key: string): Effect.Effect<boolean, never, never>;
1876
+ completeInboundDelivery(key: string, runIds: ReadonlyArray<string>): Effect.Effect<void, never, never>;
1877
+ releaseInboundDelivery(key: string): Effect.Effect<void, never, never>;
1878
+ claimEvent(record: FoundryEventRecord): Effect.Effect<boolean, never, never>;
1879
+ putEvent(record: FoundryEventRecord): Effect.Effect<void, never, never>;
1880
+ listEvents(): Effect.Effect<FoundryEventRecord[], never, never>;
1881
+ putPendingInbound(record: FoundryPendingInbound): Effect.Effect<void, never, never>;
1882
+ deletePendingInbound(id: string): Effect.Effect<void, never, never>;
1883
+ listPendingInbound(): Effect.Effect<FoundryPendingInbound[], never, never>;
1884
+ getActivation(id: string): Effect.Effect<FoundryActivationRecord | null, never, never>;
1885
+ putActivation(activation: FoundryActivationRecord): Effect.Effect<void, never, never>;
1886
+ listActivations(workspaceId?: string): Effect.Effect<FoundryActivationRecord[], never, never>;
1887
+ getConversation(id: string): Effect.Effect<Conversation | null, never, never>;
1888
+ putConversation(conversation: Conversation): Effect.Effect<void, never, never>;
1889
+ listConversations(agentId: string): Effect.Effect<Conversation[], never, never>;
1890
+ getWorkspaceEntry(workspaceId: string, key: string): Effect.Effect<WorkspaceEntry | null, never, never>;
1891
+ putWorkspaceEntry(entry: WorkspaceEntry): Effect.Effect<void, never, never>;
1892
+ compareAndSetWorkspaceEntry(entry: WorkspaceEntry, expectedUpdatedAt: string | null): Effect.Effect<boolean, never, never>;
1893
+ listWorkspaceEntries(workspaceId: string): Effect.Effect<WorkspaceEntry[], never, never>;
1894
+ getWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner): Effect.Effect<EnvSnapshot | null, never, never>;
1895
+ putWorkingEnvironmentSnapshot(owner: FoundryWorkingEnvironmentSnapshotOwner, snapshot: EnvSnapshot): Effect.Effect<void, never, never>;
1896
+ putInboxItem(item: SharedInboxItem): Effect.Effect<void, never, never>;
1897
+ listInboxItems(workspaceId: string): Effect.Effect<SharedInboxItem[], never, never>;
1898
+ putTask(task: FoundryTask): Effect.Effect<void, never, never>;
1899
+ listTasks(workspaceId: string): Effect.Effect<FoundryTask[], never, never>;
1900
+ listEnvironment(scope: {
1901
+ readonly workspaceId: string;
1902
+ readonly agentId?: string;
1903
+ readonly conversationId?: string;
1904
+ }): Effect.Effect<EnvironmentValue[], never, never>;
1905
+ }
1906
+ declare function createAgentInstance(definitionId: string, options?: CreateAgentInstanceOptions, provisioningKey?: string): AgentInstance;
1907
+ /** Code-authoring helper; instance data stores the referenced definition id. */
1908
+ declare function defineAgentInstance(definition: FoundryAgentDefinition, options?: CreateAgentInstanceOptions): AgentInstance;
1909
+ /** Rehydrate a durable adapter record into Foundry's immutable runtime shape. */
1910
+ declare function reconstructAgentInstance(agent: AgentInstance): AgentInstance;
1911
+ declare function createConversation(agent: AgentInstance, options?: CreateConversationOptions): Conversation;
1912
+
1913
+ /**
1914
+ * A sibling agent this one may hand work to, named by its route
1915
+ * (`"coder"` for `agents/coder/agent.ts`). Delegates are named rather than
1916
+ * imported so the delegating agent's process never loads the worker's
1917
+ * dependencies: a fast voice agent should not start up carrying a sandbox SDK.
1918
+ */
1919
+ type FoundryDelegate = string | FoundryDelegateOptions;
1920
+ interface FoundryDelegateOptions {
1921
+ /** Route of the worker definition. */
1922
+ readonly agent: string;
1923
+ /** What the worker is for. The delegating model reads this to choose. */
1924
+ readonly description?: string;
1925
+ }
1926
+ type FoundryDelegationStatus = "working" | "waiting" | "completed" | "failed" | "cancelled";
1927
+ /**
1928
+ * One handed-off task. Its id is also the worker conversation's id, and the
1929
+ * record lives on that conversation's `context.delegation`.
1930
+ */
1931
+ interface FoundryDelegation {
1932
+ readonly id: string;
1933
+ /** Route of the worker definition. */
1934
+ readonly to: string;
1935
+ /** The worker instance: one per delegating instance and route. */
1936
+ readonly workerAgentId: string;
1937
+ readonly workspaceId: string;
1938
+ readonly from: {
1939
+ readonly definitionId: string;
1940
+ readonly agentId: string;
1941
+ readonly conversationId: string;
1942
+ readonly runId: string;
1943
+ };
1944
+ readonly task: string;
1945
+ readonly status: FoundryDelegationStatus;
1946
+ /** The open question while status is "waiting". */
1947
+ readonly question?: string;
1948
+ readonly result?: string;
1949
+ readonly error?: string;
1950
+ /**
1951
+ * Bookkeeping: an update for the delegating conversation, or replies for the
1952
+ * worker, not handed over yet. Foundry hands them over again after a restart.
1953
+ */
1954
+ readonly undelivered?: "result" | "question" | "failed";
1955
+ readonly pendingReplies?: ReadonlyArray<string>;
1956
+ readonly pendingReplyIds?: ReadonlyArray<string>;
1957
+ readonly updateId?: string;
1958
+ readonly createdAt: string;
1959
+ readonly updatedAt: string;
1960
+ }
1961
+ /** What reaches the delegating conversation. */
1962
+ type FoundryDelegationUpdate = {
1963
+ readonly kind: "result";
1964
+ readonly delegationId: string;
1965
+ readonly agent: string;
1966
+ readonly task: string;
1967
+ readonly result: string;
1968
+ } | {
1969
+ readonly kind: "question";
1970
+ readonly delegationId: string;
1971
+ readonly agent: string;
1972
+ readonly task: string;
1973
+ readonly question: string;
1974
+ } | {
1975
+ readonly kind: "failed";
1976
+ readonly delegationId: string;
1977
+ readonly agent: string;
1978
+ readonly task: string;
1979
+ readonly error: string;
1980
+ };
1981
+ /** What reaches a worker: an answer to its question, or more instructions. */
1982
+ interface FoundryDelegationReply {
1983
+ readonly kind: "reply";
1984
+ readonly delegationId: string;
1985
+ /** Route of the delegating definition. */
1986
+ readonly from: string;
1987
+ readonly message: string;
1988
+ }
1989
+ /**
1990
+ * An inbound transmission event for a conversation that already has a run:
1991
+ * it joins that run's turn, or waits for the conversation, instead of
1992
+ * starting a second run beside it.
1993
+ */
1994
+ interface FoundryTransmissionDelivery {
1995
+ readonly kind: "transmission";
1996
+ /** The pending-inbound record that keeps this event until a run finishes with it. */
1997
+ readonly pendingId: string;
1998
+ readonly routeId: string;
1999
+ readonly eventId: string;
2000
+ /** The event as the run reads it: the serialized `<transmission>`, or the transmission's own rendering. */
2001
+ readonly message: string;
2002
+ }
2003
+ type FoundryConversationDelivery = (FoundryDelegationUpdate | FoundryDelegationReply | FoundryTransmissionDelivery | {
2004
+ readonly kind: "agent-message";
2005
+ readonly pendingId: string;
2006
+ readonly message: string;
2007
+ }) & {
2008
+ readonly deliveryId?: string;
2009
+ readonly request?: FoundryRequest;
2010
+ /** Durable journal identity; the filesystem mailbox is only a live transport. */
2011
+ readonly durable?: {
2012
+ readonly id: string;
2013
+ readonly event: AgentEvent;
2014
+ readonly policy: FoundryEventPolicy;
2015
+ };
2016
+ };
2017
+ interface DelegationCommandBase {
2018
+ readonly id: string;
2019
+ readonly definitionId: string;
2020
+ readonly agentId: string;
2021
+ readonly conversationId: string;
2022
+ readonly workspaceId: string;
2023
+ readonly delegationId: string;
2024
+ }
2025
+ type FoundryDelegationCommand = (DelegationCommandBase & {
2026
+ readonly type: "delegate";
2027
+ readonly to: string;
2028
+ readonly task: string;
2029
+ }) | (DelegationCommandBase & {
2030
+ readonly type: "delegate.reply";
2031
+ readonly message: string;
2032
+ }) | (DelegationCommandBase & {
2033
+ readonly type: "delegate.ask";
2034
+ readonly question: string;
2035
+ });
2036
+
2037
+ /** A stable address. Events never guess which of an agent's conversations is active. */
2038
+ interface FoundryEventTarget {
2039
+ readonly agentId: string;
2040
+ readonly conversationId: string;
2041
+ }
2042
+ interface FoundryEventPolicy {
2043
+ /** While busy, join at the next event boundary. While idle, wake or wait for a turn. */
2044
+ readonly whenIdle?: "wake" | "defer";
2045
+ /** A deferred event wakes after this delay; omission means wait for the next turn. */
2046
+ readonly deferTimeoutMs?: number;
2047
+ }
2048
+ interface FoundryMessageOptions extends FoundryEventPolicy {
2049
+ /** Omit to address the worker's stable default conversation. */
2050
+ readonly conversationId?: string;
2051
+ /** Stable caller-provided id for retries. Scoped to the addressed conversation. */
2052
+ readonly id?: string;
2053
+ readonly expiresAt?: string;
2054
+ }
2055
+ /** Adapter-backed outbox/inflight/receipt record; completed records retain deduplication ids. */
2056
+ interface FoundryEventRecord {
2057
+ readonly id: string;
2058
+ readonly target: FoundryEventTarget;
2059
+ readonly definitionId: string;
2060
+ readonly workspaceId: string;
2061
+ readonly event: AgentEvent;
2062
+ readonly policy: FoundryEventPolicy;
2063
+ readonly delivery: FoundryConversationDelivery;
2064
+ readonly status: "pending" | "acknowledged" | "expired";
2065
+ readonly runId?: string;
2066
+ readonly createdAt: string;
2067
+ }
2068
+
2069
+ export { BindingId as $, type AgentHandlerContext as A, type AgentAssemblyContext as B, type Conversation as C, type AgentAssemblyOptions as D, type EnvironmentValue as E, type FoundryDelegationUpdate as F, AgentDefinitionId as G, type AgentDefinitionSurfaceContext as H, type InboundDeliveryClaim as I, type AgentFactoryContext as J, AgentId as K, type AgentInstallContext as L, type AgentInstallation as M, type AgentInstallationKind as N, OutboundRoute as O, type PlaybookSubscription as P, type AgentMessageReceipt as Q, type AgentPlaybookInput as R, type SharedInboxItem as S, type AgentProvisioningPolicy as T, type AgentRuntimeControls as U, type AnyFoundryAgent as V, type WorkspaceEntry as W, type AppRestrictions as X, type ApplicationConnectionContext as Y, type ApplicationConnectionState as Z, type ApplicationConnectionStatus as _, type FoundryDataAdapter as a, type FoundryCapabilityKind as a$, BindingNotFound as a0, CapabilityId as a1, type ComposedAgentPlaybook as a2, type ComposedAgentPlaybookInput as a3, type ConnectionReceiveInput as a4, type CreateAgentInstanceOptions as a5, type CreateConversationOptions as a6, type CustomProvisionedAgent as a7, type CustomProvisioningContext as a8, type DefineAgentOptions as a9, FOUNDRY_CORE_COMMAND_EVENT as aA, FOUNDRY_EVENT_PREFIX as aB, FOUNDRY_EXECUTION_MARKER as aC, FOUNDRY_LAYER_BRAND as aD, FOUNDRY_MCP_BRAND as aE, FOUNDRY_MEMORY_BRAND as aF, FOUNDRY_PLAYBOOK_ACTION_BRAND as aG, FOUNDRY_REPL_BRAND as aH, FOUNDRY_SCHEDULE_BRAND as aI, FOUNDRY_SHARED_TOOL_BRAND as aJ, FOUNDRY_SUBSCRIBER_BRAND as aK, FOUNDRY_TRANSMISSION_BRAND as aL, FOUNDRY_TRANSMISSION_EVENT_BRAND as aM, FOUNDRY_TRANSMISSION_PREDICATE_BRAND as aN, FOUNDRY_WORKING_ENVIRONMENT_BRAND as aO, type FoundryAccountSessionAdapter as aP, type FoundryAgent as aQ, type FoundryAgentComponent as aR, type FoundryAgentComposition as aS, type FoundryAgentConventionModule as aT, type FoundryAgentDefinition as aU, type FoundryAgentMode as aV, type FoundryApp as aW, type FoundryApplicationConnection as aX, type FoundryCall as aY, type FoundryCallContext as aZ, type FoundryCallOptions as a_, type DefineConnectionOptions as aa, type DefineFoundryReplOptions as ab, type DefineFoundryScheduleOptions as ac, type DefineFoundrySubagentOptions as ad, type DefineFoundryWorkingEnvironmentOptions as ae, type DefinePlaybookSubscriptionOptions as af, type DefinitionConfigInput as ag, type DurableSubagentOptions as ah, type DurableSubagentOwnership as ai, type DurableSubagents as aj, EMPTY_AGENT_COMPOSITION as ak, EMPTY_CAPABILITY_REGISTRY as al, EMPTY_NATIVE_REGISTRY as am, type EgressAdapter as an, type EgressContext as ao, EventId as ap, EventNotFound as aq, EventReference as ar, FOUNDRY_AGENT_APPLICATION_BRAND as as, FOUNDRY_AGENT_BRAND as at, FOUNDRY_AGENT_DEFINITION_BRAND as au, FOUNDRY_AGENT_FILE_ENV as av, FOUNDRY_AGENT_ROUTE_ENV as aw, FOUNDRY_APPLICATION_ENV as ax, FOUNDRY_COMPOSED_PLAYBOOK_BRAND as ay, FOUNDRY_CONNECTION_BRAND as az, type AgentInstance as b, type FoundrySuspension as b$, type FoundryCapabilityManifest as b0, type FoundryCapabilityManifestEntry as b1, type FoundryCapabilityRegistry as b2, type FoundryCompositionSource as b3, type FoundryContextProvider as b4, type FoundryCoreCommand as b5, type FoundryDelegate as b6, type FoundryDelegateOptions as b7, type FoundryDelegation as b8, type FoundryDelegationReply as b9, type FoundryMeshConfig as bA, type FoundryMessageInput as bB, type FoundryMessageOptions as bC, type FoundryMountedRepl as bD, type FoundryNativeManifest as bE, type FoundryNativeManifestEntry as bF, type FoundryNativeRegistry as bG, type FoundryPlaybookAction as bH, type FoundryProgrammaticToolContext as bI, type FoundryProgrammaticToolSelection as bJ, type FoundryProgrammaticTools as bK, type FoundryPythonReplDefinition as bL, type FoundryReplDefinition as bM, type FoundryRequest as bN, type FoundryResolvedMcp as bO, type FoundryResolver as bP, type FoundryResult as bQ, type FoundryRouteMap as bR, type FoundryScheduleDefinition as bS, type FoundryScheduleTiming as bT, type FoundryScheduleTimingInput as bU, type FoundrySharedTool as bV, type FoundrySubagentToolContext as bW, type FoundrySubscriber as bX, type FoundrySubscriberOptions as bY, type FoundrySubscriberSelection as bZ, type FoundrySurfaceContext as b_, type FoundryDelegationStatus as ba, type FoundryDomainError as bb, type FoundryEventPolicy as bc, type FoundryEventTarget as bd, type FoundryExecutionContext as be, type FoundryFactsOptions as bf, type FoundryFormsOptions as bg, type FoundryGoalsOptions as bh, type FoundryGuidanceHandles as bi, type FoundryGuidanceScope as bj, type FoundryHookDefinition as bk, type FoundryInstallable as bl, type FoundryInstanceProvisioner as bm, type FoundryJavaScriptReplDefinition as bn, type FoundryLayer as bo, type FoundryLayerOptions as bp, type FoundryLayerReference as bq, type FoundryLayerSelection as br, type FoundryLispReplDefinition as bs, type FoundryListResolver as bt, type FoundryMcp as bu, type FoundryMcpOptions as bv, type FoundryMemoryProfile as bw, type FoundryMemoryProfileOptions as bx, type FoundryMemoryReference as by, type FoundryMemorySelection as bz, type FoundryActivationRecord as c, defineConnection as c$, type FoundryToolBody as c0, type FoundryTransmission as c1, type FoundryTransmissionDelivery as c2, type FoundryTransmissionEvent as c3, type FoundryTransmissionPredicate as c4, type FoundryVfs as c5, type FoundryVfsHandle as c6, type FoundryWorkingEnvironmentCreateContext as c7, type FoundryWorkingEnvironmentDefinition as c8, type FoundryWorkingEnvironmentPersistenceAdapter as c9, RouteNotFound as cA, RunGrant as cB, RunId as cC, type SharedToolOptions as cD, TopologyConflict as cE, type TransmissionEventDirection as cF, type TransmissionEventOptions as cG, TransmissionId as cH, type TransmissionOptions as cI, type TransmissionPredicateOptions as cJ, type TransmissionSerializationContext as cK, type UpdateAgentInstanceOptions as cL, type UpdateConversationOptions as cM, composeAgent as cN, composePlaybook as cO, configureLayer as cP, configureMemory as cQ, createAgentInstance as cR, createConversation as cS, createFoundryCoreTools as cT, createInstalledApplicationTransmissionTools as cU, defineAgent as cV, defineAgentApplication as cW, defineAgentFromModule as cX, defineAgentInstance as cY, defineApp as cZ, defineCall as c_, type FoundryWorkingEnvironmentPersistenceContext as ca, GrantResolutionError as cb, type InboundContract as cc, type InferAgentInput as cd, type InferAgentOutput as ce, type InferInboundEvent as cf, type InferOutboundInput as cg, type InferOutboundOutput as ch, type IngressAdapter as ci, type IngressContext as cj, type InstallationSelection as ck, type McpAdapterFactory as cl, MemoryFoundryDataAdapter as cm, type OutboundContract as cn, type PlaybookActionOptions as co, type PlaybookDirective as cp, type PlaybookDirectiveInput as cq, type PlaybookMatch as cr, type PlaybookMatchInput as cs, type PlaybookOutboundDirective as ct, type PlaybookOutboundInput as cu, type PlaybookSubscriptionTarget as cv, type PlaybookSubscriptionTargetInput as cw, ReplyPolicy as cx, Route as cy, RouteId as cz, type ProvisionAgentOptions as d, defineFacts as d0, defineForms as d1, defineGoals as d2, defineLayer as d3, defineMcp as d4, defineMemory as d5, definePlaybookAction as d6, definePlaybookSubscription as d7, defineRepl as d8, defineRoutes as d9, reconstructAgentInstance as dA, reconstructPlaybook as dB, reconstructPlaybookSubscription as dC, restrictApp as dD, routeFromInternalAgentName as dE, toGloveMessage as dF, toGloveRequestInput as dG, transmissionPredicate as dH, defineSchedule as da, defineSharedTool as db, defineSubagent as dc, defineSubscriber as dd, defineTransmission as de, defineTransmissionEvent as df, defineTransmissionPredicate as dg, defineWorkingEnvironment as dh, foundryDataEnvironmentPersistence as di, foundryGuidanceSubject as dj, install as dk, installRegistry as dl, installationKey as dm, installedApplicationTransmissionToolName as dn, internalAgentName as dp, isFoundryAgent as dq, isFoundryAgentDefinition as dr, isFoundryCapability as ds, isFoundryLayer as dt, isFoundrySchedule as du, isFoundrySubscriber as dv, isFoundryTransmission as dw, isInboxCapableStore as dx, mountAgentDefinitionMemory as dy, mountFoundrySurfaces as dz, type FoundryEventRecord as e, type FoundryPendingInbound as f, type FoundryWorkingEnvironmentSnapshotOwner as g, type FoundryTask as h, type AgentPlaybook as i, type AnyFoundryTransmission as j, AccountReference as k, type InferAccountMetadata as l, AgentBinding as m, type FoundryAgentApplication as n, InboundRoute as o, type CapabilityDefinition as p, type InferInboundConfig as q, type InferOutboundConfig as r, type AccountContract as s, AccountId as t, AccountNotFound as u, AccountSessionUnavailable as v, AccountSummary as w, type AgentApplicationContribution as x, type AgentApplicationInstallContext as y, type AgentApplicationOptions as z };