glove-foundry 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  FoundryRuntime,
4
4
  FoundryServer,
5
5
  writeGeneratedTypes
6
- } from "./chunk-2GXPSIRL.js";
6
+ } from "./chunk-DTFCEX67.js";
7
7
  import {
8
8
  DEFAULT_FOUNDRY_CONFIG
9
9
  } from "./chunk-ZFNMFE3T.js";
@@ -11,9 +11,9 @@ import "./chunk-J7ZBJM54.js";
11
11
  import {
12
12
  EMPTY_FOUNDRY_APPLICATION,
13
13
  isFoundryApplication
14
- } from "./chunk-EJZJAVNG.js";
15
- import "./chunk-AC6SRI5V.js";
16
- import "./chunk-64UBLGYM.js";
14
+ } from "./chunk-EUGKVW3J.js";
15
+ import "./chunk-J6NHL4SM.js";
16
+ import "./chunk-CYOIHSUX.js";
17
17
 
18
18
  // src/cli.ts
19
19
  import { watch } from "node:fs";
@@ -1,5 +1,5 @@
1
- import { StoreAdapter, Displaymanager, DisplayManagerAdapter, Slot, AgentEvent, Message, TokenConsumptionCounter } from 'glove-core';
2
- import { t as AccountId, k as AccountReference, u as AccountNotFound, cH as TransmissionId, cz as RouteId, cy as Route, cA as RouteNotFound, cE as TopologyConflict, $ as BindingId, m as AgentBinding, a0 as BindingNotFound, K as AgentId, ar as EventReference, ap as EventId, aq as EventNotFound, cC as RunId, v as AccountSessionUnavailable, a as FoundryDataAdapter, bm as FoundryInstanceProvisioner, aU as FoundryAgentDefinition, cB as RunGrant, cb as GrantResolutionError, j as AnyFoundryTransmission, b2 as FoundryCapabilityRegistry, bG as FoundryNativeRegistry, bN as FoundryRequest, a5 as CreateAgentInstanceOptions, b as AgentInstance, bC as FoundryMessageOptions, Q as AgentMessageReceipt, bd as FoundryEventTarget, bc as FoundryEventPolicy, C as Conversation, e as FoundryEventRecord, c as FoundryActivationRecord, f as FoundryPendingInbound, h as FoundryTask, S as SharedInboxItem, a6 as CreateConversationOptions, i as AgentPlaybook, P as PlaybookSubscription, af as DefinePlaybookSubscriptionOptions, Z as ApplicationConnectionState, cL as UpdateAgentInstanceOptions, cM as UpdateConversationOptions, W as WorkspaceEntry, E as EnvironmentValue, bB as FoundryMessageInput, bQ as FoundryResult, b0 as FoundryCapabilityManifest, bE as FoundryNativeManifest, M as AgentInstallation, ba as FoundryDelegationStatus, b8 as FoundryDelegation, bR as FoundryRouteMap, w as AccountSummary, V as AnyFoundryAgent } from './event-delivery-BaYe6d9w.js';
1
+ import { StoreAdapter, AgentEvent, Message, TokenConsumptionCounter } from 'glove-core';
2
+ import { v as AccountId, m as AccountReference, w as AccountNotFound, cZ as TransmissionId, cR as RouteId, cQ as Route, cS as RouteNotFound, cW as TopologyConflict, a1 as BindingId, o as AgentBinding, a2 as BindingNotFound, M as AgentId, av as EventReference, at as EventId, au as EventNotFound, cU as RunId, x as AccountSessionUnavailable, b as FoundryDataAdapter, bz as FoundryInstanceProvisioner, h as FoundryApproval, aZ as FoundryAgentDefinition, cT as RunGrant, ct as GrantResolutionError, l as AnyFoundryTransmission, be as FoundryCapabilityRegistry, bX as FoundryNativeRegistry, c3 as FoundryRequest, a7 as CreateAgentInstanceOptions, c as AgentInstance, bT as FoundryMessageOptions, T as AgentMessageReceipt, bp as FoundryEventTarget, bo as FoundryEventPolicy, C as Conversation, f as FoundryEventRecord, d as FoundryActivationRecord, g as FoundryPendingInbound, j as FoundryTask, S as SharedInboxItem, a8 as CreateConversationOptions, k as AgentPlaybook, P as PlaybookSubscription, aj as DefinePlaybookSubscriptionOptions, $ as ApplicationConnectionState, d1 as UpdateAgentInstanceOptions, d2 as UpdateConversationOptions, W as WorkspaceEntry, E as EnvironmentValue, bS as FoundryMessageInput, c6 as FoundryResult, b7 as FoundryApprovalStatus, b4 as FoundryApprovalDecision, bc as FoundryCapabilityManifest, bV as FoundryNativeManifest, Q as AgentInstallation, bm as FoundryDelegationStatus, bk as FoundryDelegation, bR as FoundryMeshThreadStatus, bQ as FoundryMeshThread, c7 as FoundryRouteMap, y as AccountSummary, Y as AnyFoundryAgent } from './event-delivery-CNCsVqi8.js';
3
3
  import * as effect_Brand from 'effect/Brand';
4
4
  import { Context, Effect, Layer, Schema } from 'effect';
5
5
  import { FoundryStationDaemonAdapter } from './station.js';
@@ -114,6 +114,25 @@ interface FoundryApplicationOptions {
114
114
  readonly requestAuthorization?: FoundryRequestAuthorizationAdapter<unknown>;
115
115
  /** User-owned strategy for subscriptions using `provisioning.mode = "custom"`. */
116
116
  readonly provisioner?: FoundryInstanceProvisioner;
117
+ /**
118
+ * How approvals work. They are durable when the data adapter stores
119
+ * approvals and events (`FileFoundryDataAdapter` and
120
+ * `MemoryFoundryDataAdapter` do): the run that asked waits `waitMs` for a
121
+ * decision, then suspends; the approval stays open for `expiresAfterMs`;
122
+ * and a decision made later resumes the run at the tool call that asked.
123
+ */
124
+ readonly approvals?: {
125
+ /** How long a run waits for a decision before it suspends. Default 60 s (5 min when approvals are not durable). */
126
+ readonly waitMs?: number;
127
+ /** How long a durable approval stays open. Default 7 days. */
128
+ readonly expiresAfterMs?: number;
129
+ /**
130
+ * Where a person decides one approval: a page of your app. Foundry keeps
131
+ * it on the approval (`url`) so whatever tells the person, such as a
132
+ * message or an email, can link straight to it.
133
+ */
134
+ readonly url?: (approval: FoundryApproval) => string | undefined;
135
+ };
117
136
  readonly services?: Layer.Layer<AccountDirectory | TopologyStore | EventStore, unknown>;
118
137
  }
119
138
  type FoundryApplication = Readonly<FoundryApplicationOptions> & {
@@ -324,58 +343,6 @@ interface DiscoveredFoundryRegistry {
324
343
  }>;
325
344
  }
326
345
 
327
- declare const FOUNDRY_APPROVAL_DIRECTORY_ENV = "GLOVE_FOUNDRY_APPROVAL_DIRECTORY";
328
- type FoundryApprovalDecision = "approve" | "deny";
329
- type FoundryApprovalStatus = "pending" | "approved" | "denied" | "expired" | "cancelled";
330
- interface FoundryApproval {
331
- readonly id: string;
332
- readonly runId: string;
333
- readonly definitionId: string;
334
- readonly agentId: string;
335
- readonly conversationId: string;
336
- readonly workspaceId: string;
337
- readonly toolName: string;
338
- readonly toolInput: unknown;
339
- readonly status: FoundryApprovalStatus;
340
- readonly requestedAt: string;
341
- readonly expiresAt: string;
342
- readonly resolvedAt?: string;
343
- }
344
- declare function createFoundryApproval(directory: string, input: {
345
- readonly runId: string;
346
- readonly definitionId: string;
347
- readonly agentId: string;
348
- readonly conversationId: string;
349
- readonly workspaceId: string;
350
- readonly toolName: string;
351
- readonly toolInput: unknown;
352
- readonly timeoutMs?: number;
353
- }): Promise<FoundryApproval>;
354
- declare function listFoundryApprovals(directory: string, filter?: {
355
- readonly runId?: string;
356
- readonly status?: FoundryApprovalStatus;
357
- }): Promise<ReadonlyArray<FoundryApproval>>;
358
- declare function resolveFoundryApproval(directory: string, id: string, decision: FoundryApprovalDecision): Promise<FoundryApproval>;
359
- declare class FoundryApprovalDisplayManager extends Displaymanager implements DisplayManagerAdapter {
360
- private readonly context;
361
- constructor(context: {
362
- readonly directory?: string;
363
- readonly runId: string;
364
- readonly definitionId: string;
365
- readonly agentId: string;
366
- readonly conversationId: string;
367
- readonly workspaceId: string;
368
- readonly signal: AbortSignal;
369
- readonly emit: (event: {
370
- readonly type: string;
371
- readonly data?: unknown;
372
- }) => void;
373
- });
374
- pushAndWait<I, O>(slot: Omit<Slot<I>, "id">): Promise<O>;
375
- }
376
- /** Add fail-closed per-input permissions to a custom store that omitted them. */
377
- declare function withFoundryPermissions(store: StoreAdapter): StoreAdapter;
378
-
379
346
  interface FoundryRun<TOutput = unknown> {
380
347
  readonly id: string;
381
348
  readonly agent: string;
@@ -486,6 +453,10 @@ declare class FoundryRuntime {
486
453
  private readonly pendingInboundByRun;
487
454
  /** Recently settled runs, for a record assigned to a run that already finished. */
488
455
  private readonly settledRuns;
456
+ /** How runs treat approvals; durable when the data adapter can keep them. */
457
+ private readonly approvalPolicy;
458
+ /** Approval records change one at a time. */
459
+ private approvalWrites;
489
460
  private started;
490
461
  private stopping;
491
462
  private disposed;
@@ -604,17 +575,49 @@ declare class FoundryRuntime {
604
575
  readonly runId?: string;
605
576
  readonly status?: FoundryApprovalStatus;
606
577
  }): Promise<ReadonlyArray<FoundryApproval>>;
578
+ /** One approval: what a link to it opens. Null when there is no such approval. */
579
+ getApproval(approvalId: string): Promise<FoundryApproval | null>;
580
+ /**
581
+ * Decide an approval. When the run that asked is still waiting, it reads the
582
+ * decision and carries on. When it is not (it suspended, timed out, or the
583
+ * runtime restarted since), the decision goes to the conversation as a
584
+ * durable event, and the run that takes it resumes the turn at the tool
585
+ * call that asked: approved, the call runs; denied, it is refused.
586
+ */
607
587
  resolveApproval(approvalId: string, decision: FoundryApprovalDecision): Promise<FoundryApproval>;
588
+ private reportResolved;
589
+ private withApprovals;
590
+ private reportApprovalFailure;
591
+ /** Stored approvals, expired where their time ran out, plus requests not recorded yet. Call inside withApprovals. */
592
+ private currentApprovals;
593
+ private withApprovalUrl;
594
+ /** What a run reported about one of its approvals, kept in the data adapter. */
595
+ private recordApprovalEvent;
596
+ /**
597
+ * A run ended. Its approvals still open no longer have anyone waiting:
598
+ * they stay open, and a decision resumes the conversation. A decision the
599
+ * run never read (it ended first) is handed over now.
600
+ */
601
+ private settleApprovalsOf;
602
+ private cancelApprovalsOf;
603
+ /** After a restart: open approvals have no run waiting, and decided ones may still be owed. */
604
+ private reconcileApprovals;
605
+ /**
606
+ * Hand a decision to the conversation that asked, as a durable event. The
607
+ * run that takes it resumes the turn at the waiting tool call. If the
608
+ * conversation moved on, the event tells the agent what was decided.
609
+ */
610
+ private resumeApproval;
608
611
  capabilityManifest(definitionId: string): FoundryCapabilityManifest;
609
612
  nativeManifest(definitionId: string): FoundryNativeManifest;
610
613
  listInstallations(agentId: string): Promise<ReadonlyArray<AgentInstallation>>;
611
614
  installCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
612
615
  uninstallCapability(agentId: string, installation: AgentInstallation): Promise<AgentInstance>;
613
616
  listAccounts(): Promise<{
617
+ label?: string | undefined;
614
618
  id: string & effect_Brand.Brand<"FoundryAccountId">;
615
619
  transmissionId: string & effect_Brand.Brand<"FoundryTransmissionId">;
616
620
  externalAccountId: string;
617
- label?: string | undefined;
618
621
  metadata: {
619
622
  readonly [x: string]: unknown;
620
623
  };
@@ -744,6 +747,41 @@ declare class FoundryRuntime {
744
747
  private executeDelegationCommand;
745
748
  private startDelegation;
746
749
  /** Report a worker's finished run back to whoever delegated to it. */
750
+ /** Every thread, newest first, optionally narrowed to who started it or who it went to. */
751
+ listThreads(filter?: {
752
+ /** The agent that started the thread. */
753
+ readonly agentId?: string;
754
+ /** The conversation that started the thread. */
755
+ readonly conversationId?: string;
756
+ /** The agent the thread was sent to. */
757
+ readonly to?: string;
758
+ readonly status?: FoundryMeshThreadStatus;
759
+ }): Promise<ReadonlyArray<FoundryMeshThread>>;
760
+ /**
761
+ * Older thread records kept their own lists of messages not handed over yet.
762
+ * Move them to the event journal once; message ids keep a retry from
763
+ * delivering twice.
764
+ */
765
+ private redeliverThreads;
766
+ /** The open threads a conversation started, oldest first. */
767
+ private openThreadsFrom;
768
+ private loadThread;
769
+ private updateThread;
770
+ private starterTarget;
771
+ private recipientTarget;
772
+ /**
773
+ * Hand mesh messages to one side of a thread. Messages, replies and
774
+ * failures go through durable delivery. A read receipt only ever reaches a
775
+ * run that is listening, and is dropped otherwise.
776
+ */
777
+ private deliverMesh;
778
+ /** A run's mesh call: answered through its request, so the tool hears the outcome. */
779
+ private runMeshCommand;
780
+ /** The agents an agent may see and message: its workspace, narrowed by its definition's rule. */
781
+ private meshPeers;
782
+ private executeMeshCommand;
783
+ /** When the recipient's run on a thread ends, its reply (or its failure) goes back. */
784
+ private settleThread;
747
785
  private handleRunSettled;
748
786
  private enqueueCoreRequest;
749
787
  /**
@@ -910,6 +948,8 @@ declare class FoundryClient<TRoutes extends FoundryRouteMap> {
910
948
  readonly runId?: string;
911
949
  readonly status?: FoundryApprovalStatus;
912
950
  }): Promise<ReadonlyArray<FoundryApproval>>;
951
+ /** One approval, by id: what a link to it opens. */
952
+ approval(approvalId: string): Promise<FoundryApproval>;
913
953
  resolveApproval(approvalId: string, decision: FoundryApprovalDecision): Promise<FoundryApproval>;
914
954
  manifest(): Promise<{
915
955
  agents: FoundryManifest;
@@ -936,4 +976,4 @@ declare class FoundryClient<TRoutes extends FoundryRouteMap> {
936
976
  }
937
977
  declare function createFoundryClient<TRoutes extends FoundryRouteMap = Record<string, AnyFoundryAgent>>(options?: FoundryClientOptions): FoundryClient<TRoutes>;
938
978
 
939
- export { grantResolverLive as $, AccountDirectory as A, type BindingFilter as B, type FoundryRequestAuthorizationAdapter as C, type DiscoveredAgent as D, EMPTY_FOUNDRY_APPLICATION as E, FoundryRuntime as F, type FoundryRequestAuthorizationInput as G, type FoundryRun as H, FoundryRunHandle as I, FoundryRuntimeError as J, type FoundryRuntimeOptions as K, type FoundrySteerHandleResult as L, type FoundrySteerResult as M, GrantResolver as N, ManifestCompilationError as O, MemoryObservabilityAdapter as P, type RouteFilter as Q, type ResolveGrantRequest as R, compileApplicationManifest as S, TopologyStore as T, createFoundryApproval as U, createFoundryClient as V, type WaitOptions as W, createManifest as X, defineApplication as Y, discoverAgents as Z, findAgentFiles as _, type FoundryManifest as a, isFoundryApplication as a0, listFoundryApprovals as a1, memoryAccountDirectory as a2, memoryEventStore as a3, memoryTopologyStore as a4, resolveFoundryApproval as a5, routeFromAgentFile as a6, withFoundryPermissions as a7, type AccountFilter as b, type AccountSessionAdapter as c, type AccountSessionRequest as d, type EventFilter as e, EventStore as f, FOUNDRY_APPLICATION_BRAND as g, FOUNDRY_APPROVAL_DIRECTORY_ENV as h, type FoundryApplication as i, FoundryApplicationManifest as j, type FoundryApplicationOptions as k, type FoundryApproval as l, type FoundryApprovalDecision as m, FoundryApprovalDisplayManager as n, type FoundryApprovalStatus as o, FoundryClient as p, type FoundryClientAuthorizationAdapter as q, type FoundryClientOptions as r, type FoundryConversationTranscript as s, type FoundryEvent as t, type FoundryEventCategory as u, type FoundryHealth as v, type FoundryManifestAgent as w, FoundryManifestCapability as x, FoundryManifestTransmission as y, type FoundryObservabilityAdapter as z };
979
+ export { AccountDirectory as A, type BindingFilter as B, type FoundryRuntimeOptions as C, type DiscoveredAgent as D, EMPTY_FOUNDRY_APPLICATION as E, FoundryRuntime as F, type FoundrySteerHandleResult as G, type FoundrySteerResult as H, GrantResolver as I, MemoryObservabilityAdapter as J, type RouteFilter as K, compileApplicationManifest as L, ManifestCompilationError as M, createFoundryClient as N, createManifest as O, defineApplication as P, discoverAgents as Q, type ResolveGrantRequest as R, findAgentFiles as S, TopologyStore as T, grantResolverLive as U, isFoundryApplication as V, type WaitOptions as W, memoryAccountDirectory as X, memoryEventStore as Y, memoryTopologyStore as Z, routeFromAgentFile as _, type FoundryManifest as a, type AccountFilter as b, type AccountSessionAdapter as c, type AccountSessionRequest as d, type EventFilter as e, EventStore as f, FOUNDRY_APPLICATION_BRAND as g, type FoundryApplication as h, FoundryApplicationManifest as i, type FoundryApplicationOptions as j, FoundryClient as k, type FoundryClientAuthorizationAdapter as l, type FoundryClientOptions as m, type FoundryConversationTranscript as n, type FoundryEvent as o, type FoundryEventCategory as p, type FoundryHealth as q, type FoundryManifestAgent as r, FoundryManifestCapability as s, FoundryManifestTransmission as t, type FoundryObservabilityAdapter as u, type FoundryRequestAuthorizationAdapter as v, type FoundryRequestAuthorizationInput as w, type FoundryRun as x, FoundryRunHandle as y, FoundryRuntimeError as z };
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'glove-core';
2
- import './event-delivery-BaYe6d9w.js';
3
- export { p as FoundryClient, q as FoundryClientAuthorizationAdapter, r as FoundryClientOptions, v as FoundryHealth, I as FoundryRunHandle, L as FoundrySteerHandleResult, W as WaitOptions, V as createFoundryClient } from './client-BgpgsnoO.js';
2
+ import './event-delivery-CNCsVqi8.js';
3
+ export { k as FoundryClient, l as FoundryClientAuthorizationAdapter, m as FoundryClientOptions, q as FoundryHealth, y as FoundryRunHandle, G as FoundrySteerHandleResult, W as WaitOptions, N as createFoundryClient } from './client-CekanYLW.js';
4
4
  import 'effect';
5
5
  import 'zod';
6
6
  import 'glove-mesh';
package/dist/client.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  FoundryClient,
3
3
  FoundryRunHandle,
4
4
  createFoundryClient
5
- } from "./chunk-EEHGAWXM.js";
5
+ } from "./chunk-L5JQVTHD.js";
6
6
  export {
7
7
  FoundryClient,
8
8
  FoundryRunHandle,
package/dist/config.d.ts CHANGED
@@ -29,6 +29,13 @@ interface FoundryConfig {
29
29
  readonly execution?: FoundryExecutionConfig;
30
30
  readonly observability?: {
31
31
  readonly maxEvents?: number;
32
+ /**
33
+ * Record what each model request was sent: system prompt, messages,
34
+ * runtime context and tools, compactly. The inspector's Network and
35
+ * Context views read these. On by default; `false` leaves them out of
36
+ * `/api/events` for systems that must not keep prompts.
37
+ */
38
+ readonly modelRequests?: boolean;
32
39
  };
33
40
  readonly branding?: FoundryBrandingConfig;
34
41
  readonly strictFileRoutes?: boolean;