@forgeax/engine-tool-runtime 0.1.29 → 0.1.31
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/api.d.ts +72 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +849 -472
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +35 -0
- package/package.json +1 -1
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ToolCallerIdentity, ToolContribution, ToolDescriptor, ToolExecutionOwner, ToolRealm, ToolRun, ToolRunOptions } from './types.js';
|
|
2
|
+
export type ToolApiProviderState = 'pending' | 'active' | 'revoking' | 'revoked' | 'failed';
|
|
3
|
+
export interface ToolApiProviderInput {
|
|
4
|
+
/** Stable provider identity within one source. */
|
|
5
|
+
readonly providerId: string;
|
|
6
|
+
/** Host/source identity. Different sources may expose the same operation id. */
|
|
7
|
+
readonly sourceId: string;
|
|
8
|
+
readonly realm: ToolRealm;
|
|
9
|
+
readonly generation?: number;
|
|
10
|
+
readonly fiberId?: string | number;
|
|
11
|
+
readonly module?: string;
|
|
12
|
+
readonly fiberState?: string;
|
|
13
|
+
/** Async plugin activation stays non-callable until explicitly activated. */
|
|
14
|
+
readonly initialState?: 'pending' | 'active';
|
|
15
|
+
readonly tools: readonly ToolContribution[];
|
|
16
|
+
/** Domain authorization remains owned by the provider. */
|
|
17
|
+
readonly authorize?: (caller: ToolCallerIdentity | undefined, operation: ToolDescriptor) => boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ToolApiProviderSnapshot {
|
|
20
|
+
readonly owner: ToolExecutionOwner;
|
|
21
|
+
readonly state: ToolApiProviderState;
|
|
22
|
+
readonly fiberState?: string;
|
|
23
|
+
readonly callable: boolean;
|
|
24
|
+
readonly operationIds: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export interface ToolApiRecord {
|
|
27
|
+
readonly descriptor: ToolDescriptor;
|
|
28
|
+
readonly owner: ToolExecutionOwner;
|
|
29
|
+
readonly providerState: ToolApiProviderState;
|
|
30
|
+
readonly declared: true;
|
|
31
|
+
readonly callable: boolean;
|
|
32
|
+
readonly fiberState?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ToolApiSnapshot {
|
|
35
|
+
readonly providers: readonly ToolApiProviderSnapshot[];
|
|
36
|
+
readonly operations: readonly ToolApiRecord[];
|
|
37
|
+
}
|
|
38
|
+
export interface ToolApiProviderHandle {
|
|
39
|
+
readonly owner: ToolExecutionOwner;
|
|
40
|
+
readonly snapshot: () => ToolApiProviderSnapshot;
|
|
41
|
+
/** Mark a pending provider callable after its domain apply succeeds. */
|
|
42
|
+
readonly activate: (fiberState?: string) => void;
|
|
43
|
+
/** Mark a pending/active provider failed without making it callable. */
|
|
44
|
+
readonly fail: (reason?: string, fiberState?: string) => void;
|
|
45
|
+
/** Withdraw admission and wait for every executor to actually exit. */
|
|
46
|
+
readonly revoke: (reason?: string) => Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export interface ToolApiRunOptions extends Omit<ToolRunOptions, 'owner'> {
|
|
49
|
+
/** Explicit provider route. Required when multiple sources expose an id. */
|
|
50
|
+
readonly providerId?: string;
|
|
51
|
+
readonly sourceId?: string;
|
|
52
|
+
/** Provider generation observed by the caller. */
|
|
53
|
+
readonly generation?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface ToolApi {
|
|
56
|
+
readonly snapshot: () => ToolApiSnapshot;
|
|
57
|
+
readonly list: () => readonly ToolApiRecord[];
|
|
58
|
+
readonly describe: (id: string, sourceId?: string) => readonly ToolApiRecord[];
|
|
59
|
+
readonly registerProvider: (input: ToolApiProviderInput) => ToolApiProviderHandle;
|
|
60
|
+
readonly run: <TResult = unknown>(id: string, args: unknown, options?: ToolApiRunOptions) => ToolRun<TResult>;
|
|
61
|
+
readonly subscribe: (listener: (snapshot: ToolApiSnapshot) => void) => () => void;
|
|
62
|
+
/** Revoke all providers and wait for their executors to exit. */
|
|
63
|
+
readonly dispose: () => Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create the one effective Tool API capability for a Context/owner.
|
|
67
|
+
*
|
|
68
|
+
* Declarations are retained for inspection, while calls are admitted only
|
|
69
|
+
* through an active provider binding. The command tree and clients may cache
|
|
70
|
+
* the returned projection, but they never own executors or provider state.
|
|
71
|
+
*/
|
|
72
|
+
export declare function createToolApi(): ToolApi;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { createToolApi, type ToolApi, type ToolApiProviderHandle, type ToolApiProviderInput, type ToolApiProviderSnapshot, type ToolApiProviderState, type ToolApiRecord, type ToolApiRunOptions, type ToolApiSnapshot, } from './api.js';
|
|
1
2
|
export { type ArtifactManifestValidation, createArtifactManifest, createArtifactRef, createPreviewArtifactManifest, createSnapshotRef, isSerializableValue, type PreviewArtifactIdentity, type PreviewArtifactKind, type PreviewArtifactManifest, type PreviewArtifactManifestEntry, type PreviewArtifactManifestValidation, type PreviewArtifactRole, type ToolArtifactIdentity, type ToolArtifactManifest, type ToolArtifactManifestEntry, validateArtifactManifest, validateArtifactRefs, validatePreviewArtifactManifest, } from './artifacts.js';
|
|
2
3
|
export { createCapabilityResolver, createRealmCapabilityMatrix, createServiceCapability, defineToolCapability, type RealmBootstrapValidation, type RealmCapability, type RealmCapabilityInput, type RealmCapabilityMatrix, type ServiceAdmissionExpectation, type ServiceAdmissionRef, type ServiceCapability, validateRealmBootstrapPayload, } from './capability.js';
|
|
3
4
|
export { type CarrierError, type CarrierErrorCode, type CarrierLease, type CarrierLeaseRequest, type CarrierOffer, type CarrierPhase, type CarrierResult, type CarrierState, type CarrierStateMachine, type CarrierStateMachineOptions, createCarrierStateMachine, } from './carrier.js';
|
|
@@ -10,4 +11,4 @@ export { createToolRuntime, defineTool, type ToolRuntime } from './runtime.js';
|
|
|
10
11
|
export { isSnapshotRef, terminalSnapshot } from './snapshot.js';
|
|
11
12
|
export { createExclusiveTiming, type ExclusiveTiming, type ExclusiveTimingResult, finishToolTiming, startToolTiming, } from './timing.js';
|
|
12
13
|
export { type AuthenticatedCarrierTransport, type AuthenticatedCarrierTransportOptions, type AuthenticatedLoopbackTransport, type AuthenticatedLoopbackTransportOptions, type CarrierExecutionRequest, type CarrierTransport, CarrierTransportError, createAuthenticatedCarrierTransport, createAuthenticatedLoopbackTransport, createLoopbackTransport, type ServiceWireHandler, type ServiceWireRequest, } from './transport.js';
|
|
13
|
-
export type { ArtifactRef, JsonPrimitive, JsonValue, SnapshotRef, ToolCapability, ToolCapabilityResolver, ToolCapabilityResult, ToolCleanupCensus, ToolCleanupReport, ToolContribution, ToolDescriptor, ToolDomainFailure, ToolEvidenceKind, ToolExecutionContext, ToolExecutor, ToolExecutorResult, ToolExecutorValue, ToolPhaseObservation, ToolPreviewContract, ToolRealm, ToolRecoveryAction, ToolResourceKind, ToolResourceObservation, ToolRun, ToolRunEvent, ToolRunOptions, ToolRuntimeError, ToolRuntimeErrorCode, ToolSchema, ToolSchemaResult, ToolSnapshotInput, ToolSubjectRef, ToolTerminal, ToolTiming, ToolTimingPhase, } from './types.js';
|
|
14
|
+
export type { ArtifactRef, JsonPrimitive, JsonValue, SnapshotRef, ToolCallerIdentity, ToolCapability, ToolCapabilityResolver, ToolCapabilityResult, ToolCleanupCensus, ToolCleanupReport, ToolContribution, ToolDescriptor, ToolDomainFailure, ToolEvidenceKind, ToolExecutionContext, ToolExecutionOwner, ToolExecutor, ToolExecutorResult, ToolExecutorValue, ToolPhaseObservation, ToolPreviewContract, ToolRealm, ToolRecoveryAction, ToolResourceKind, ToolResourceObservation, ToolRun, ToolRunEvent, ToolRunOptions, ToolRuntimeError, ToolRuntimeErrorCode, ToolSchema, ToolSchemaResult, ToolSnapshotInput, ToolSubjectRef, ToolTerminal, ToolTiming, ToolTimingPhase, } from './types.js';
|