glove-foundry 0.11.0 → 0.13.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,6 +1,6 @@
1
1
  import {
2
2
  resolveResolvable
3
- } from "./chunk-NWFOY3L7.js";
3
+ } from "./chunk-WK2O4GIB.js";
4
4
 
5
5
  // src/guidance.ts
6
6
  import { createHash } from "node:crypto";
@@ -1155,6 +1155,7 @@ var CONVENTION_EXPORTS = [
1155
1155
  "durableSubagents",
1156
1156
  "eventDelivery",
1157
1157
  "prepareEvent",
1158
+ "builtins",
1158
1159
  "answerWaitMs",
1159
1160
  "memory",
1160
1161
  "goals",
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  FoundryRuntime,
4
4
  FoundryServer,
5
5
  writeGeneratedTypes
6
- } from "./chunk-YCW66WKQ.js";
6
+ } from "./chunk-SE44NTGZ.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-4WBQ7XVF.js";
15
- import "./chunk-2JCISE2U.js";
16
- import "./chunk-NWFOY3L7.js";
14
+ } from "./chunk-RAZARYUH.js";
15
+ import "./chunk-5ZYOBBOK.js";
16
+ import "./chunk-WK2O4GIB.js";
17
17
 
18
18
  // src/cli.ts
19
19
  import { watch } from "node:fs";
@@ -1,5 +1,5 @@
1
1
  import { StoreAdapter, AgentEvent, Message, TokenConsumptionCounter } from 'glove-core';
2
- import { B as AccountId, r as AccountReference, D as AccountNotFound, d8 as TransmissionId, d0 as RouteId, c$ as Route, d1 as RouteNotFound, d5 as TopologyConflict, a6 as BindingId, t as AgentBinding, a7 as BindingNotFound, U as AgentId, aB as EventReference, ay as EventId, az as EventNotFound, d3 as RunId, G as AccountSessionUnavailable, d as FoundryDataAdapter, bI as FoundryInstanceProvisioner, m as FoundryApproval, b3 as FoundryAgentDefinition, d2 as RunGrant, cE as GrantResolutionError, q as AnyFoundryTransmission, bk as FoundryCapabilityRegistry, c4 as FoundryNativeRegistry, cc as FoundryRequest, ac as CreateAgentInstanceOptions, e as AgentInstance, c0 as FoundryMessageOptions, Z as AgentMessageReceipt, bx as FoundryEventTarget, bu as FoundryEventPolicy, C as Conversation, h as FoundryEventRecord, f as FoundryActivationRecord, l as FoundryPendingInbound, o as FoundryTask, S as SharedInboxItem, ad as CreateConversationOptions, p as AgentPlaybook, P as PlaybookSubscription, ao as DefinePlaybookSubscriptionOptions, a4 as ApplicationConnectionState, dc as UpdateAgentInstanceOptions, dd as UpdateConversationOptions, W as WorkspaceEntry, E as EnvironmentValue, b$ as FoundryMessageInput, cf as FoundryResult, bd as FoundryApprovalStatus, ba as FoundryApprovalDecision, bi as FoundryCapabilityManifest, c2 as FoundryNativeManifest, X as AgentInstallation, bs as FoundryDelegationStatus, bq as FoundryDelegation, b_ as FoundryMeshThreadStatus, bZ as FoundryMeshThread, k as FoundryScheduleOccurrenceFilter, j as FoundryScheduleOccurrence, cg as FoundryRouteMap, H as AccountSummary, a1 as AnyFoundryAgent } from './event-delivery-BfSL9sGo.js';
2
+ import { B as AccountId, r as AccountReference, D as AccountNotFound, dm as TransmissionId, de as RouteId, dd as Route, df as RouteNotFound, dj as TopologyConflict, a6 as BindingId, t as AgentBinding, a7 as BindingNotFound, U as AgentId, aC as EventReference, az as EventId, aA as EventNotFound, dh as RunId, G as AccountSessionUnavailable, d as FoundryDataAdapter, bO as FoundryInstanceProvisioner, m as FoundryApproval, bc as FoundryApplicationMesh, b5 as FoundryAgentDefinition, dg as RunGrant, cS as GrantResolutionError, q as AnyFoundryTransmission, bq as FoundryCapabilityRegistry, ci as FoundryNativeRegistry, cq as FoundryRequest, ac as CreateAgentInstanceOptions, e as AgentInstance, ce as FoundryMessageOptions, Z as AgentMessageReceipt, bD as FoundryEventTarget, bA as FoundryEventPolicy, C as Conversation, h as FoundryEventRecord, f as FoundryActivationRecord, l as FoundryPendingInbound, o as FoundryTask, S as SharedInboxItem, ad as CreateConversationOptions, p as AgentPlaybook, P as PlaybookSubscription, ap as DefinePlaybookSubscriptionOptions, a4 as ApplicationConnectionState, dr as UpdateAgentInstanceOptions, ds as UpdateConversationOptions, W as WorkspaceEntry, E as EnvironmentValue, cd as FoundryMessageInput, ct as FoundryResult, bg as FoundryApprovalStatus, bd as FoundryApprovalDecision, bo as FoundryCapabilityManifest, cg as FoundryNativeManifest, X as AgentInstallation, by as FoundryDelegationStatus, bw as FoundryDelegation, ca as FoundryMeshThread, cc as FoundryMeshThreadStatus, c as FoundryMeshMessage, k as FoundryScheduleOccurrenceFilter, j as FoundryScheduleOccurrence, cu as FoundryRouteMap, H as AccountSummary, a1 as AnyFoundryAgent } from './event-delivery-CWxarW6L.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';
@@ -133,6 +133,12 @@ interface FoundryApplicationOptions {
133
133
  */
134
134
  readonly url?: (approval: FoundryApproval) => string | undefined;
135
135
  };
136
+ /**
137
+ * The hosted mesh under your rules: peers across workspaces, a gate on
138
+ * every message, and threads bound and committed to your own record.
139
+ * Omitted, agents on the mesh see their own workspace, ungated.
140
+ */
141
+ readonly mesh?: FoundryApplicationMesh;
136
142
  readonly services?: Layer.Layer<AccountDirectory | TopologyStore | EventStore, unknown>;
137
143
  }
138
144
  type FoundryApplication = Readonly<FoundryApplicationOptions> & {
@@ -462,6 +468,8 @@ declare class FoundryRuntime {
462
468
  private readonly pendingInboundByRun;
463
469
  /** Recently settled runs, for a record assigned to a run that already finished. */
464
470
  private readonly settledRuns;
471
+ /** The built-ins each restricted run mounted, as it reported them. Runs without a policy are absent. */
472
+ private readonly runBuiltins;
465
473
  /** How runs treat approvals; durable when the data adapter can keep them. */
466
474
  private readonly approvalPolicy;
467
475
  /** Approval records change one at a time. */
@@ -763,6 +771,8 @@ declare class FoundryRuntime {
763
771
  private executeDelegationCommand;
764
772
  private startDelegation;
765
773
  /** Report a worker's finished run back to whoever delegated to it. */
774
+ /** One mesh thread, by id. Null when there is none. */
775
+ getThread(threadId: string): Promise<FoundryMeshThread | null>;
766
776
  /** Every thread, newest first, optionally narrowed to who started it or who it went to. */
767
777
  listThreads(filter?: {
768
778
  /** The agent that started the thread. */
@@ -774,9 +784,11 @@ declare class FoundryRuntime {
774
784
  readonly status?: FoundryMeshThreadStatus;
775
785
  }): Promise<ReadonlyArray<FoundryMeshThread>>;
776
786
  /**
777
- * Older thread records kept their own lists of messages not handed over yet.
778
- * Move them to the event journal once; message ids keep a retry from
779
- * delivering twice.
787
+ * At start: older thread records kept their own lists of messages not
788
+ * handed over yet; move them to the event journal once. Then finish what a
789
+ * stop cut short: messages committed (or being committed) to the
790
+ * application's record and not handed over, and drafts decided but not
791
+ * delivered or dropped. Message ids keep a retry from delivering twice.
780
792
  */
781
793
  private redeliverThreads;
782
794
  /** The open threads a conversation started, oldest first. */
@@ -785,19 +797,88 @@ declare class FoundryRuntime {
785
797
  private updateThread;
786
798
  private starterTarget;
787
799
  private recipientTarget;
800
+ private sideTarget;
788
801
  /**
789
802
  * Hand mesh messages to one side of a thread. Messages, replies and
790
803
  * failures go through durable delivery. A read receipt only ever reaches a
791
804
  * run that is listening, and is dropped otherwise.
792
805
  */
793
806
  private deliverMesh;
807
+ /**
808
+ * Send messages to one side of a thread. Under the application's mesh they
809
+ * go through the thread's outbox: committed to the application's record
810
+ * first, then handed over, so the record and the journal agree. A side
811
+ * that was taken over gets nothing; the record still does.
812
+ */
813
+ private sendToSide;
814
+ /** Commit each outbox message to the application's record, then deliver it. */
815
+ private flushOutbox;
816
+ private retryOutbox;
817
+ private reportMeshFailure;
818
+ private meshHookContext;
819
+ private meshRefusal;
820
+ /** The application's gate. Without one, everything is delivered. */
821
+ private gateMesh;
822
+ /**
823
+ * Act on the gate's decision for one message to one side. Held and drafted
824
+ * messages are stored on the thread, not delivered; `onDeliver` is what
825
+ * delivery changes on the thread, applied only when it happens, because
826
+ * the side waiting for it must not see a message it has not been given.
827
+ */
828
+ private dispatchMesh;
829
+ /** A drafted message waits on an approval nobody resumes a run for. */
830
+ private draftApproval;
831
+ /** A drafted message's approval was decided: deliver it, or drop it. */
832
+ private settleMeshDraft;
833
+ /**
834
+ * Release a message the application's gate held: deliver it (committed to
835
+ * your record first) or discard it. The sender is not told either way.
836
+ * Drafts are decided through their approval instead.
837
+ */
838
+ releaseMeshMessage(threadId: string, messageId: string, decision: "deliver" | "discard"): Promise<FoundryMeshThread>;
839
+ private releaseHeld;
840
+ /**
841
+ * A person's message in a thread, entered by the application from its own
842
+ * record (so it is not committed again). It reaches each agent still in
843
+ * the thread as a message from a person, and starts the recipient working
844
+ * again. Pass `id` (your record's message id) to make a retry a no-op.
845
+ */
846
+ meshHumanMessage(threadId: string, input: {
847
+ readonly authorId: string;
848
+ readonly name?: string;
849
+ readonly text: string;
850
+ readonly id?: string;
851
+ }): Promise<FoundryMeshMessage>;
852
+ /**
853
+ * A person takes a thread over. The agents named (default: both) leave it:
854
+ * nothing more is delivered to them in this thread, what they send to it
855
+ * is refused, and a recipient run working on it is cancelled without a
856
+ * reply. Messages to a side that left still reach your record.
857
+ */
858
+ meshTakeOver(threadId: string, options: {
859
+ readonly by: string;
860
+ readonly agentId?: string;
861
+ }): Promise<FoundryMeshThread>;
794
862
  /** A run's mesh call: answered through its request, so the tool hears the outcome. */
795
863
  private runMeshCommand;
796
- /** The agents an agent may see and message: its workspace, narrowed by its definition's rule. */
864
+ /**
865
+ * The agents an agent may see and message: its workspace, or whoever the
866
+ * application's `mesh.peers` names; then narrowed by its definition's rule.
867
+ */
797
868
  private meshPeers;
798
869
  private executeMeshCommand;
870
+ /** Remember on the starter's conversation that it started a thread. */
871
+ private noteStartedThread;
799
872
  /** When the recipient's run on a thread ends, its reply (or its failure) goes back. */
800
873
  private settleThread;
874
+ /** The gate for a recipient's final answer, when the application has one. */
875
+ private gateReply;
876
+ /**
877
+ * A run whose definition restricts built-ins may only send the commands its
878
+ * mounted tools send. Anything else is refused, however it was emitted.
879
+ */
880
+ private withheldBuiltinRefusal;
881
+ private refuseCoreCommand;
801
882
  private handleRunSettled;
802
883
  private enqueueCoreRequest;
803
884
  /**
@@ -996,6 +1077,28 @@ declare class FoundryClient<TRoutes extends FoundryRouteMap> {
996
1077
  /** One approval, by id: what a link to it opens. */
997
1078
  approval(approvalId: string): Promise<FoundryApproval>;
998
1079
  resolveApproval(approvalId: string, decision: FoundryApprovalDecision): Promise<FoundryApproval>;
1080
+ /** Mesh threads, newest first: by who started them, the conversation that did, the recipient or status. */
1081
+ threads(filter?: {
1082
+ readonly agentId?: string;
1083
+ readonly conversationId?: string;
1084
+ readonly to?: string;
1085
+ readonly status?: FoundryMeshThreadStatus;
1086
+ }): Promise<ReadonlyArray<FoundryMeshThread>>;
1087
+ thread(threadId: string): Promise<FoundryMeshThread>;
1088
+ /** A person's message in a thread, from your record: `runtime.meshHumanMessage`. */
1089
+ meshHumanMessage(threadId: string, input: {
1090
+ readonly authorId: string;
1091
+ readonly name?: string;
1092
+ readonly text: string;
1093
+ readonly id?: string;
1094
+ }): Promise<FoundryMeshMessage>;
1095
+ /** A person takes a thread over: `runtime.meshTakeOver`. */
1096
+ meshTakeOver(threadId: string, options: {
1097
+ readonly by: string;
1098
+ readonly agentId?: string;
1099
+ }): Promise<FoundryMeshThread>;
1100
+ /** Deliver or discard a message the application's gate held: `runtime.releaseMeshMessage`. */
1101
+ releaseMeshMessage(threadId: string, messageId: string, decision: "deliver" | "discard"): Promise<FoundryMeshThread>;
999
1102
  manifest(): Promise<{
1000
1103
  agents: FoundryManifest;
1001
1104
  application: FoundryApplicationManifest;
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'glove-core';
2
- import './event-delivery-BfSL9sGo.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-B4Emyeek.js';
2
+ import './event-delivery-CWxarW6L.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-Dvli7Y1v.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-N2GVJ257.js";
5
+ } from "./chunk-HNBAEHHS.js";
6
6
  export {
7
7
  FoundryClient,
8
8
  FoundryRunHandle,