@dual-os/sdk 0.8.0-next.0 → 0.8.0-next.2
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/README.md +5 -17
- package/dist/Action.d.ts +0 -1
- package/dist/Action.js +1 -2
- package/dist/AgentChannel.d.ts +27 -930
- package/dist/AgentChannel.d.ts.map +1 -1
- package/dist/AgentChannel.js +53 -161
- package/dist/AgentChannel.js.map +1 -1
- package/dist/AgentChannelConformance.d.ts +8 -501
- package/dist/AgentChannelConformance.d.ts.map +1 -1
- package/dist/AgentChannelConformance.js +4 -5
- package/dist/AgentChannelConformance.js.map +1 -1
- package/dist/AgentChannelRuntime.d.ts +0 -1
- package/dist/AgentChannelRuntime.d.ts.map +1 -1
- package/dist/AgentChannelRuntime.js +8 -10
- package/dist/AgentChannelRuntime.js.map +1 -1
- package/dist/AiProvider.d.ts +0 -1
- package/dist/AiProvider.js +1 -2
- package/dist/AuthMethod.d.ts +0 -1
- package/dist/AuthMethod.js +1 -2
- package/dist/AuthMethodBinding.d.ts +0 -1
- package/dist/AuthMethodBinding.js +1 -2
- package/dist/AuthMethodExecution.d.ts +0 -1
- package/dist/AuthMethodExecution.js +1 -2
- package/dist/ConnectionResolver.d.ts +0 -1
- package/dist/ConnectionResolver.js +1 -2
- package/dist/DefinitionError.d.ts +0 -1
- package/dist/DefinitionError.js +1 -2
- package/dist/DualRegistry.d.ts +0 -1
- package/dist/DualRegistry.js +1 -2
- package/dist/DualRuntime.d.ts +0 -1
- package/dist/DualRuntime.js +1 -2
- package/dist/Files.d.ts +0 -1
- package/dist/Files.js +1 -2
- package/dist/Group.d.ts +0 -1
- package/dist/Group.js +1 -2
- package/dist/Http.d.ts +0 -1
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js +4 -5
- package/dist/Http.js.map +1 -1
- package/dist/Mcp.d.ts +0 -1
- package/dist/Mcp.js +1 -2
- package/dist/OAuth2TokenRefresher.d.ts +0 -1
- package/dist/OAuth2TokenRefresher.js +1 -2
- package/dist/OAuthFlow.d.ts +0 -1
- package/dist/OAuthFlow.js +1 -2
- package/dist/Plugin.d.ts +0 -1
- package/dist/Plugin.js +1 -2
- package/dist/PluginRuntime.d.ts +0 -1
- package/dist/PluginRuntime.js +1 -2
- package/dist/Runner.js +3 -4
- package/dist/Runner.js.map +1 -1
- package/dist/ToolFile.d.ts +0 -1
- package/dist/ToolFile.js +1 -2
- package/dist/Trigger.d.ts +0 -1
- package/dist/Trigger.js +1 -2
- package/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/internal/auth-context.d.ts +0 -2
- package/dist/internal/auth-context.d.ts.map +1 -1
- package/dist/internal/auth-execution.d.ts +0 -2
- package/dist/internal/auth-execution.d.ts.map +1 -1
- package/dist/internal/auth-execution.js +1 -2
- package/dist/internal/auth-runtime.d.ts +0 -2
- package/dist/internal/auth-runtime.d.ts.map +1 -1
- package/dist/internal/auth-runtime.js +1 -2
- package/dist/internal/capabilities.d.ts +0 -2
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/capabilities.js +1 -2
- package/dist/internal/children.d.ts +0 -2
- package/dist/internal/children.d.ts.map +1 -1
- package/dist/internal/children.js +1 -2
- package/dist/internal/collection-utils.d.ts +0 -2
- package/dist/internal/collection-utils.d.ts.map +1 -1
- package/dist/internal/collection-utils.js +1 -2
- package/dist/internal/dual/actions.d.ts +0 -2
- package/dist/internal/dual/actions.d.ts.map +1 -1
- package/dist/internal/dual/actions.js +1 -2
- package/dist/internal/dual/invoke.d.ts +0 -2
- package/dist/internal/dual/invoke.d.ts.map +1 -1
- package/dist/internal/dual/invoke.js +1 -2
- package/dist/internal/dual/registry.d.ts +1 -5
- package/dist/internal/dual/registry.d.ts.map +1 -1
- package/dist/internal/dual/registry.js +1 -2
- package/dist/internal/dual/registry.js.map +1 -1
- package/dist/internal/dual/triggers.d.ts +0 -2
- package/dist/internal/dual/triggers.d.ts.map +1 -1
- package/dist/internal/dual/triggers.js +1 -2
- package/dist/internal/handler-context.d.ts +0 -2
- package/dist/internal/handler-context.d.ts.map +1 -1
- package/dist/internal/handler-context.js +1 -2
- package/dist/internal/identifier.d.ts +0 -2
- package/dist/internal/identifier.d.ts.map +1 -1
- package/dist/internal/identifier.js +1 -2
- package/dist/internal/plugin-handlers.d.ts +0 -2
- package/dist/internal/plugin-handlers.d.ts.map +1 -1
- package/dist/internal/plugin-handlers.js +5 -4
- package/dist/internal/plugin-handlers.js.map +1 -1
- package/dist/internal/proto.d.ts +0 -2
- package/dist/internal/proto.d.ts.map +1 -1
- package/dist/internal/proto.js +1 -2
- package/dist/internal/schema-runtime.d.ts +0 -2
- package/dist/internal/schema-runtime.d.ts.map +1 -1
- package/dist/internal/schema-runtime.js +1 -2
- package/dist/internal/trigger-runtime-shared.d.ts +0 -2
- package/dist/internal/trigger-runtime-shared.d.ts.map +1 -1
- package/dist/internal/trigger-runtime-shared.js +1 -2
- package/dist/internal/trigger-runtime.d.ts +0 -2
- package/dist/internal/trigger-runtime.d.ts.map +1 -1
- package/dist/internal/trigger-runtime.js +1 -2
- package/dist/internal/types.d.ts +0 -2
- package/dist/internal/types.d.ts.map +1 -1
- package/dist/remote-runtime.d.ts +0 -1
- package/dist/remote-runtime.js +1 -2
- package/package.json +6 -7
- package/src/AgentChannel.ts +52 -150
- package/src/AgentChannelConformance.ts +2 -6
- package/src/AgentChannelRuntime.ts +11 -14
- package/src/Http.ts +21 -4
- package/src/Runner.ts +5 -4
- package/src/internal/dual/registry.ts +0 -2
- package/src/internal/plugin-handlers.ts +5 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proto.d.ts","names":[],"sources":["../../src/internal/proto.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"proto.d.ts","names":[],"sources":["../../src/internal/proto.ts"],"mappings":";qBAGa;EACX"}
|
package/dist/internal/proto.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Pipeable } from "effect";
|
|
2
|
-
|
|
2
|
+
// src/internal/proto.ts
|
|
3
3
|
/** Shared prototype mixin for all SDK definition objects. */
|
|
4
4
|
const PipeableProto = { pipe() {
|
|
5
5
|
return Pipeable.pipeArguments(this, arguments);
|
|
6
6
|
} };
|
|
7
|
-
//#endregion
|
|
8
7
|
export { PipeableProto };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=proto.js.map
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
//#region src/internal/schema-runtime.d.ts
|
|
3
2
|
export declare function decodeJson<SchemaDef extends Schema.Top>(schema: SchemaDef, value: unknown): Effect.Effect<SchemaDef["Type"], Schema.SchemaError, SchemaDef["DecodingServices"]>;
|
|
4
3
|
export declare const decodeJsonMapError: <SchemaDef extends Schema.Top, Error>(schema: SchemaDef, value: unknown, mapError: (error: Schema.SchemaError) => Error) => Effect.Effect<SchemaDef["Type"], Error, SchemaDef["DecodingServices"]>;
|
|
5
|
-
//#endregion
|
|
6
4
|
//# sourceMappingURL=schema-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-runtime.d.ts","names":[],"sources":["../../src/internal/schema-runtime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema-runtime.d.ts","names":[],"sources":["../../src/internal/schema-runtime.ts"],"mappings":";wBAEgB,WAAW,kBAAkB,OAAO,KAClD,QAAQ,WACR,iBACC,OAAO,OAAO,mBAAmB,OAAO,aAAa;qBAI3C,qBAAsB,kBAAkB,OAAO,KAAK,OAAK,QAC5D,WAAS,gBACH,WACH,OAAO,OAAO,gBAAgB,UACxC,OAAO,OAAO,mBAAmB,OAAO"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
|
|
2
|
+
// src/internal/schema-runtime.ts
|
|
3
3
|
function decodeJson(schema, value) {
|
|
4
4
|
return Schema.decodeUnknownEffect(Schema.toCodecJson(schema))(value);
|
|
5
5
|
}
|
|
6
6
|
const decodeJsonMapError = (schema, value, mapError) => decodeJson(schema, value).pipe(Effect.mapError(mapError));
|
|
7
|
-
//#endregion
|
|
8
7
|
export { decodeJson, decodeJsonMapError };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=schema-runtime.js.map
|
|
@@ -2,7 +2,6 @@ import { ConnectionResolutionContext, Service } from "../ConnectionResolver.js";
|
|
|
2
2
|
import { AuthResolutionRequirements, AuthSchemaRequirements, RuntimeConnectionErrorsFor } from "./auth-execution.js";
|
|
3
3
|
import { Any, ConfigSchema, Handler, InvalidTriggerConfigError, InvalidTriggerOutputError, InvalidTriggerStateError, KeyedEvent, OutputSchema, PollingRuntime, RuntimeContext, RuntimePhase, RuntimeTriggerEntry, StateSchema, UnsupportedTriggerRuntimeError, WebhookRuntime } from "../Trigger.js";
|
|
4
4
|
import { Context, Effect, Schema } from "effect";
|
|
5
|
-
//#region src/internal/trigger-runtime-shared.d.ts
|
|
6
5
|
type ConfigRequirements<TriggerDef extends Any> = ConfigSchema<TriggerDef>["DecodingServices"];
|
|
7
6
|
type StateDecodingRequirements<TriggerDef extends Any> = StateSchema<TriggerDef> extends Schema.Top ? Exclude<StateSchema<TriggerDef>, undefined>["DecodingServices"] : never;
|
|
8
7
|
type StateEncodingRequirements<TriggerDef extends Any> = StateSchema<TriggerDef> extends Schema.Top ? Exclude<StateSchema<TriggerDef>, undefined>["EncodingServices"] : never;
|
|
@@ -36,6 +35,5 @@ type PollHook = NonNullable<PollingRuntime<Schema.Top, Schema.Top, Schema.Top |
|
|
|
36
35
|
export declare const requireWebhookHook: <Entry extends RuntimeTriggerEntry<any, any, any, any>, Phase extends WebhookPhase>(entry: Entry, phase: Phase) => Effect.Effect<RuntimeHook<WebhookHook<Phase>>, UnsupportedTriggerRuntimeError, EntryHandler<Entry>>;
|
|
37
36
|
export declare const requirePollingHook: <Entry extends RuntimeTriggerEntry<any, any, any, any>>(entry: Entry) => Effect.Effect<RuntimeHook<PollHook>, UnsupportedTriggerRuntimeError, EntryHandler<Entry>>;
|
|
38
37
|
export declare const withRuntimeContext: <Entry extends RuntimeTriggerEntry<any, any, any, any>, Phase extends RuntimePhase, Result>(entry: Entry, phase: Phase, connectionId: string | undefined, context: ConnectionResolutionContext | undefined, run: (context: RuntimeContext<EntryAuthMethods<Entry>>) => Effect.Effect<Result, TriggerAppError<EntryTrigger<Entry>> | RuntimeConnectionErrorsFor<EntryAuthMethods<Entry>>, TriggerRuntimeRequirements<Entry, Phase>>) => Effect.Effect<Result, TriggerAppError<EntryTrigger<Entry>> | RuntimeConnectionErrorsFor<EntryAuthMethods<Entry>>, TriggerRuntimeRequirements<Entry, Phase>>;
|
|
39
|
-
//#endregion
|
|
40
38
|
export {};
|
|
41
39
|
//# sourceMappingURL=trigger-runtime-shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-runtime-shared.d.ts","names":["Trigger.Any","Trigger.ConfigSchema","Trigger.StateSchema","Trigger.OutputSchema","Trigger.RuntimeTriggerEntry","Trigger.Handler","Trigger.RuntimePhase","Trigger.InvalidTriggerConfigError","Trigger.InvalidTriggerStateError","Trigger.KeyedEvent","Trigger.InvalidTriggerOutputError","Trigger.WebhookRuntime","Trigger.PollingRuntime","Trigger.UnsupportedTriggerRuntimeError","Trigger.RuntimeContext"],"sources":["../../src/internal/trigger-runtime-shared.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"trigger-runtime-shared.d.ts","names":["Trigger.Any","Trigger.ConfigSchema","Trigger.StateSchema","Trigger.OutputSchema","Trigger.RuntimeTriggerEntry","Trigger.Handler","Trigger.RuntimePhase","Trigger.InvalidTriggerConfigError","Trigger.InvalidTriggerStateError","Trigger.KeyedEvent","Trigger.InvalidTriggerOutputError","Trigger.WebhookRuntime","Trigger.PollingRuntime","Trigger.UnsupportedTriggerRuntimeError","Trigger.RuntimeContext"],"sources":["../../src/internal/trigger-runtime-shared.ts"],"mappings":";;;;KAmBK,mBAAmB,mBAAmBA,OACzCC,aAAqB;KAElB,0BAA0B,mBAAmBD,OAChDE,YAAoB,oBAAoB,OAAO,MAC3C,QAAQA,YAAoB;KAG7B,0BAA0B,mBAAmBF,OAChDE,YAAoB,oBAAoB,OAAO,MAC3C,QAAQA,YAAoB;KAG7B,2BAA2B,mBAAmBF,OACjDG,aAAqB;;;;;;YAOX,gBAAgB,oBAAoBH;YAEpC,oBAAoB,mBAAmBA,OACjDE,YAAoB,oBAAoB,OAAO,MAC3C,QAAQA,YAAoB;YAGtB,qBAAqB,mBAAmBF,OAClDG,aAAqB;YAEX,YAAY,cAAcC,2CACpC;YACU,aAAa,cAAcA,2CACrC;YACU,iBAAiB,cAAcA,2CACzC;KACG,aAAa,cAAcA,2CAAmDC,QACjF,YAAY;YAGF,2BACV,cAAcD,yCACd,cAAcE,gBAEZ,aAAa,SACb,mBAAmB,aAAa,UAChC,0BAA0B,aAAa,WACtC,yDACG,0BAA0B,aAAa,oBAE1C,iCAAiC,2BAA2B,aAAa,qBACxE,iBAAiB,0CAGX,UACA,uBAAuB,iBAAiB,UACxC,2BAA2B,iBAAiB;qBAE3C,eAAgB,eAAe,OAAO,KAAG,mBACnC,QACT,QAAM,mBAEb,OAAO,OAAO,gBAAgBC,2BAAmC;wBA4BpD,YACd,mBACA,OAAOD,cACP,mBACA,iBACC,OAAO,kBAAkBE;wBACZ,YAAY,cAAc,OAAO,KAC/C,mBACA,OAAOF,cACP,QAAQ,OACR,iBACC,OAAO,OACR,2BACAE,0BACA;wBA6Dc,oBACd,mBACA,OAAOF,cACP,mBACA,mBACC,OAAO,kBAAkBE;wBACZ,oBAAoB,cAAc,OAAO,KACvD,mBACA,OAAOF,cACP,QAAQ,OACR,OAAO,4BACN,OAAO,OACR,8BACAE,0BACA;qBAgDW,kBAAmB,eAAe,OAAO,KAAG,mBACtC,yBACM,QACf,QAAM,oBAEb,OAAO,gBACCC,WAAmB,sBAC5BC,2BACA;UAcQ,YAAY;WACX,MAAM;WACN,SAAS,QAAQ;;KAGvB;KAEA,YAAY,cAAc,gBAAgB,YAC7CC,eAAuB,OAAO,KAAK,OAAO,KAAK,OAAO,gCAAgC;KAGnF,WAAW,YACdC,eAAuB,OAAO,KAAK,OAAO,KAAK,OAAO;qBA8B3C,qBACX,cAAcR,yCACd,cAAc,cAAY,OAEnB,OAAK,OACL,UACN,OAAO,OACR,YAAY,YAAY,SACxBS,gCACA,aAAa;qBA+BF,qBAAsB,cAAcT,yCAA+C,OACvF,UACN,OAAO,OACR,YAAY,WACZS,gCACA,aAAa;qBA+BF,qBACX,cAAcT,yCACd,cAAcE,cACd,QAEA,OAAO,OACP,OAAO,OACP,kCACA,SAAS,yCACT,MACE,SAASQ,eAAuB,iBAAiB,YAC9C,OAAO,OACV,QACA,gBAAgB,aAAa,UAAU,2BAA2B,iBAAiB,SACnF,2BAA2B,OAAO,YAEjC,OAAO,OACV,QACA,gBAAgB,aAAa,UAAU,2BAA2B,iBAAiB,SACnF,2BAA2B,OAAO"}
|
|
@@ -3,7 +3,7 @@ import { decodeJson, decodeJsonMapError } from "./schema-runtime.js";
|
|
|
3
3
|
import { authRuntimeContext, failConnectionIdNotAllowed, noAuthRuntimeContext, resolveRuntimeConnection, toNonEmptyArray } from "./auth-execution.js";
|
|
4
4
|
import { InvalidTriggerConfigError, InvalidTriggerOutputError, InvalidTriggerStateError, UnsupportedTriggerRuntimeError, handlerKey } from "../Trigger.js";
|
|
5
5
|
import { Effect, Schema } from "effect";
|
|
6
|
-
|
|
6
|
+
// src/internal/trigger-runtime-shared.ts
|
|
7
7
|
const decodeConfig = (triggerId, schema, value) => decodeJsonMapError(schema, value, (error) => new InvalidTriggerConfigError({
|
|
8
8
|
description: error.message,
|
|
9
9
|
triggerId
|
|
@@ -126,7 +126,6 @@ const withRuntimeContext = (entry, phase, connectionId, context, run) => {
|
|
|
126
126
|
if (entry.trigger.requireAuth === false && connectionId === void 0) return run(runtimeContext(noAuthRuntimeContext()));
|
|
127
127
|
return resolveRuntimeConnection("trigger", entry.triggerId, phase, entry.providerId, requiredAuthMethods, connectionId, context).pipe(Effect.flatMap((binding) => run(runtimeContext(authRuntimeContext(binding)))));
|
|
128
128
|
};
|
|
129
|
-
//#endregion
|
|
130
129
|
export { decodeConfig, decodeState, requirePollingHook, requireWebhookHook, validateOutputs, validateStateResult, withRuntimeContext };
|
|
131
130
|
|
|
132
131
|
//# sourceMappingURL=trigger-runtime-shared.js.map
|
|
@@ -2,11 +2,9 @@ import { RuntimeConnectionErrorsFor } from "./auth-execution.js";
|
|
|
2
2
|
import { EntryAuthMethods, EntryTrigger, TriggerAppError, TriggerEncodedOutput, TriggerEncodedState, TriggerIdOf, TriggerRuntimeRequirements } from "./trigger-runtime-shared.js";
|
|
3
3
|
import { ActivateSuccess, DeactivateSuccess, EmittedEventsSuccess, InvalidTriggerConfigError, InvalidTriggerOutputError, InvalidTriggerStateError, PollExecutionRequest, RuntimeTriggerEntry, UnsupportedTriggerRuntimeError, VerifySuccess, WebhookActivationRequest, WebhookExecutionRequest } from "../Trigger.js";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
|
-
//#region src/internal/trigger-runtime.d.ts
|
|
6
5
|
export declare const activate: <Entry extends RuntimeTriggerEntry<any, any, any, any>>(entry: Entry, request: WebhookActivationRequest) => Effect.Effect<ActivateSuccess<TriggerIdOf<Entry>, TriggerEncodedState<EntryTrigger<Entry>>>, InvalidTriggerConfigError | InvalidTriggerStateError | UnsupportedTriggerRuntimeError | RuntimeConnectionErrorsFor<EntryAuthMethods<Entry>> | TriggerAppError<EntryTrigger<Entry>>, TriggerRuntimeRequirements<Entry, "activate">>;
|
|
7
6
|
export declare const deactivate: <Entry extends RuntimeTriggerEntry<any, any, any, any>>(entry: Entry, request: WebhookActivationRequest) => Effect.Effect<DeactivateSuccess<TriggerIdOf<Entry>>, InvalidTriggerConfigError | InvalidTriggerStateError | UnsupportedTriggerRuntimeError | RuntimeConnectionErrorsFor<EntryAuthMethods<Entry>> | TriggerAppError<EntryTrigger<Entry>>, TriggerRuntimeRequirements<Entry, "deactivate">>;
|
|
8
7
|
export declare const verify: <Entry extends RuntimeTriggerEntry<any, any, any, any>>(entry: Entry, request: WebhookExecutionRequest) => Effect.Effect<VerifySuccess<TriggerIdOf<Entry>, TriggerEncodedState<EntryTrigger<Entry>>>, InvalidTriggerConfigError | InvalidTriggerStateError | UnsupportedTriggerRuntimeError | RuntimeConnectionErrorsFor<EntryAuthMethods<Entry>> | TriggerAppError<EntryTrigger<Entry>>, TriggerRuntimeRequirements<Entry, "verify">>;
|
|
9
8
|
export declare const parse: <Entry extends RuntimeTriggerEntry<any, any, any, any>>(entry: Entry, request: WebhookExecutionRequest) => Effect.Effect<EmittedEventsSuccess<TriggerIdOf<Entry>, "parse", TriggerEncodedOutput<EntryTrigger<Entry>>, TriggerEncodedState<EntryTrigger<Entry>>>, InvalidTriggerConfigError | InvalidTriggerStateError | InvalidTriggerOutputError | UnsupportedTriggerRuntimeError | RuntimeConnectionErrorsFor<EntryAuthMethods<Entry>> | TriggerAppError<EntryTrigger<Entry>>, TriggerRuntimeRequirements<Entry, "parse">>;
|
|
10
9
|
export declare const poll: <Entry extends RuntimeTriggerEntry<any, any, any, any>>(entry: Entry, request: PollExecutionRequest) => Effect.Effect<EmittedEventsSuccess<TriggerIdOf<Entry>, "poll", TriggerEncodedOutput<EntryTrigger<Entry>>, TriggerEncodedState<EntryTrigger<Entry>>>, InvalidTriggerConfigError | InvalidTriggerStateError | InvalidTriggerOutputError | UnsupportedTriggerRuntimeError | RuntimeConnectionErrorsFor<EntryAuthMethods<Entry>> | TriggerAppError<EntryTrigger<Entry>>, TriggerRuntimeRequirements<Entry, "poll">>;
|
|
11
|
-
//#endregion
|
|
12
10
|
//# sourceMappingURL=trigger-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-runtime.d.ts","names":["Trigger.RuntimeTriggerEntry","Trigger.WebhookActivationRequest","Trigger.ActivateSuccess","Trigger.InvalidTriggerConfigError","Trigger.InvalidTriggerStateError","Trigger.UnsupportedTriggerRuntimeError","Trigger.DeactivateSuccess","Trigger.WebhookExecutionRequest","Trigger.VerifySuccess","Trigger.EmittedEventsSuccess","Trigger.InvalidTriggerOutputError","Trigger.PollExecutionRequest"],"sources":["../../src/internal/trigger-runtime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"trigger-runtime.d.ts","names":["Trigger.RuntimeTriggerEntry","Trigger.WebhookActivationRequest","Trigger.ActivateSuccess","Trigger.InvalidTriggerConfigError","Trigger.InvalidTriggerStateError","Trigger.UnsupportedTriggerRuntimeError","Trigger.DeactivateSuccess","Trigger.WebhookExecutionRequest","Trigger.VerifySuccess","Trigger.EmittedEventsSuccess","Trigger.InvalidTriggerOutputError","Trigger.PollExecutionRequest"],"sources":["../../src/internal/trigger-runtime.ts"],"mappings":";;;;qBAoFa,WAAW,cAAcA,yCACpC,OAAO,OACP,SAASC,6BACN,OAAO,OACVC,gBAAwB,YAAY,QAAQ,oBAAoB,aAAa,UAC3EC,4BACAC,2BACAC,iCACA,2BAA2B,iBAAiB,UAC5C,gBAAgB,aAAa,SAC/B,2BAA2B;qBAchB,aAAa,cAAcL,yCACtC,OAAO,OACP,SAASC,6BACN,OAAO,OACVK,kBAA0B,YAAY,SACpCH,4BACAC,2BACAC,iCACA,2BAA2B,iBAAiB,UAC5C,gBAAgB,aAAa,SAC/B,2BAA2B;qBAgBhB,SAAS,cAAcL,yCAClC,OAAO,OACP,SAASO,4BACN,OAAO,OACVC,cAAsB,YAAY,QAAQ,oBAAoB,aAAa,UACzEL,4BACAC,2BACAC,iCACA,2BAA2B,iBAAiB,UAC5C,gBAAgB,aAAa,SAC/B,2BAA2B;qBAwBhB,QAAQ,cAAcL,yCACjC,OAAO,OACP,SAASO,4BACN,OAAO,OACVE,qBACE,YAAY,iBAEZ,qBAAqB,aAAa,SAClC,oBAAoB,aAAa,UAEjCN,4BACAC,2BACAM,4BACAL,iCACA,2BAA2B,iBAAiB,UAC5C,gBAAgB,aAAa,SAC/B,2BAA2B;qBAWhB,OAAO,cAAcL,yCAChC,OAAO,OACP,SAASW,yBACN,OAAO,OACVF,qBACE,YAAY,gBAEZ,qBAAqB,aAAa,SAClC,oBAAoB,aAAa,UAEjCN,4BACAC,2BACAM,4BACAL,iCACA,2BAA2B,iBAAiB,UAC5C,gBAAgB,aAAa,SAC/B,2BAA2B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeUnder } from "./handler-context.js";
|
|
2
2
|
import { decodeConfig, decodeState, requirePollingHook, requireWebhookHook, validateOutputs, validateStateResult, withRuntimeContext } from "./trigger-runtime-shared.js";
|
|
3
3
|
import { Effect, Record, String } from "effect";
|
|
4
|
-
|
|
4
|
+
// src/internal/trigger-runtime.ts
|
|
5
5
|
/**
|
|
6
6
|
* Shared execution skeleton for all trigger runtime phases: decode config and
|
|
7
7
|
* state, resolve the runtime connection, run the hook inside the registered
|
|
@@ -89,7 +89,6 @@ const poll = (entry, request) => runPhase({
|
|
|
89
89
|
phase: "poll",
|
|
90
90
|
request
|
|
91
91
|
});
|
|
92
|
-
//#endregion
|
|
93
92
|
export { activate, deactivate, parse, poll, verify };
|
|
94
93
|
|
|
95
94
|
//# sourceMappingURL=trigger-runtime.js.map
|
package/dist/internal/types.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { MachineIdSeparator } from "./identifier.js";
|
|
2
|
-
//#region src/internal/types.d.ts
|
|
3
2
|
export type IsAny<Value> = 0 extends 1 & Value ? true : false;
|
|
4
3
|
export type IsGenericArray<Values extends readonly unknown[]> = number extends Values["length"] ? true : false;
|
|
5
4
|
export type JoinPrefix<Prefix extends string, Identifier extends string> = Prefix extends "" ? Identifier : `${Prefix}${typeof MachineIdSeparator}${Identifier}`;
|
|
6
|
-
//#endregion
|
|
7
5
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/internal/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/internal/types.ts"],"mappings":";YAGY,MAAM,uBAAuB;YAE7B,eAAe,oDAAoD;YAInE,WAAW,uBAAuB,6BAA6B,oBACvE,gBACG,gBAAgB,qBAAqB"}
|
package/dist/remote-runtime.d.ts
CHANGED
|
@@ -580,6 +580,5 @@ export declare const execute: (request: {
|
|
|
580
580
|
readonly pluginVersion: string;
|
|
581
581
|
};
|
|
582
582
|
}, never, Service$1>;
|
|
583
|
-
//#endregion
|
|
584
583
|
export { remote_runtime_d_exports as RemoteRuntime, remote_runtime_d_exports };
|
|
585
584
|
//# sourceMappingURL=remote-runtime.d.ts.map
|
package/dist/remote-runtime.js
CHANGED
|
@@ -9,7 +9,7 @@ import { File, FileError, Service as Service$2 } from "./Files.js";
|
|
|
9
9
|
import "./remote-runtime.js";
|
|
10
10
|
import { Array, Cause, Effect, Layer, Match, Option, Predicate, Redacted, Schema, flow, pipe } from "effect";
|
|
11
11
|
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
12
|
-
|
|
12
|
+
// src/remote-runtime.ts
|
|
13
13
|
/**
|
|
14
14
|
* Data-only SDK lifecycle requests for an installed, isolated integration plugin.
|
|
15
15
|
*
|
|
@@ -361,7 +361,6 @@ const execute = Effect.fn("RemoteRuntime.execute")(function* (request) {
|
|
|
361
361
|
identity: request.identity
|
|
362
362
|
})));
|
|
363
363
|
});
|
|
364
|
-
//#endregion
|
|
365
364
|
export { Failure, FileAccess, Identity, Operation, remote_runtime_exports as RemoteRuntime, Request, Response, connectionLayer, execute, failure, filesUnavailable, remote_runtime_exports };
|
|
366
365
|
|
|
367
366
|
//# sourceMappingURL=remote-runtime.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dual-os/sdk",
|
|
3
|
-
"version": "0.8.0-next.
|
|
3
|
+
"version": "0.8.0-next.2",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**/*.js",
|
|
@@ -42,16 +42,15 @@
|
|
|
42
42
|
"./Runner": "./dist/Runner.js"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"prepack": "vp run build"
|
|
45
|
+
"prepack": "vp run build",
|
|
46
|
+
"typecheck": "tsrs --build tsconfig.json --force --pretty false"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"@effect/platform-node": "4.
|
|
49
|
-
"effect": "4.
|
|
49
|
+
"@effect/platform-node": "4.1.2",
|
|
50
|
+
"effect": "4.1.2"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@deslop/coding-standards": "0.1.1193",
|
|
53
53
|
"@types/node": "^22.15.3",
|
|
54
|
-
"bun-types": "^1.3.11"
|
|
55
|
-
"typescript": "7.0.2"
|
|
54
|
+
"bun-types": "^1.3.11"
|
|
56
55
|
}
|
|
57
56
|
}
|
package/src/AgentChannel.ts
CHANGED
|
@@ -15,14 +15,7 @@ export const Key = Schema.NonEmptyString.check(
|
|
|
15
15
|
Schema.isMaxLength(512),
|
|
16
16
|
Schema.isPattern(/^[^\p{Cc}]+$/u),
|
|
17
17
|
);
|
|
18
|
-
/**
|
|
19
|
-
* The command and result schemas a version uses. Absent means the original protocol, whose
|
|
20
|
-
* projection stays byte-identical for contracts already published with it. `v2` adds the stop
|
|
21
|
-
* event, conversation reads and output operations.
|
|
22
|
-
*/
|
|
23
|
-
export const Protocol = Schema.Literals(["v2"]);
|
|
24
|
-
export type Protocol = typeof Protocol.Type;
|
|
25
|
-
/** What a `v2` destination can show. Every channel shows `present_outcome`. */
|
|
18
|
+
/** What a destination can show. Every channel shows `present_outcome`. */
|
|
26
19
|
export const OperationKind = Schema.Literals([
|
|
27
20
|
"present_outcome",
|
|
28
21
|
"create_message",
|
|
@@ -43,9 +36,9 @@ export const Features = Schema.Struct({
|
|
|
43
36
|
/** Maximum Unicode code points per physical text message, including server-added prefixes. */
|
|
44
37
|
maxTextLength: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
45
38
|
mentions: Schema.Boolean,
|
|
46
|
-
/**
|
|
39
|
+
/** Every definition declares operations; retired catalog contracts still decode without them. */
|
|
47
40
|
operations: Schema.optionalKey(Schema.Array(OperationKind)),
|
|
48
|
-
/**
|
|
41
|
+
/** Whether `read_context` returns the conversation's earlier messages. */
|
|
49
42
|
readContext: Schema.optionalKey(Schema.Boolean),
|
|
50
43
|
replies: Schema.Boolean,
|
|
51
44
|
/** Maximum age of the original responding input before preparation and delivery. */
|
|
@@ -116,7 +109,10 @@ const ResponseHeaders = Schema.Record(
|
|
|
116
109
|
Object.keys(headers).every(name => name === "content-type" || name === "cache-control"),
|
|
117
110
|
),
|
|
118
111
|
);
|
|
119
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Bounded provider-required webhook response, returned only after request verification. A 204 or
|
|
114
|
+
* 205 response has an empty body.
|
|
115
|
+
*/
|
|
120
116
|
export const WebhookResponse = Schema.Struct({
|
|
121
117
|
body: Schema.String.check(
|
|
122
118
|
Schema.isMaxLength(65_536),
|
|
@@ -124,7 +120,11 @@ export const WebhookResponse = Schema.Struct({
|
|
|
124
120
|
),
|
|
125
121
|
headers: Schema.optionalKey(ResponseHeaders),
|
|
126
122
|
status: Schema.Int.check(Schema.isBetween({ maximum: 299, minimum: 200 })),
|
|
127
|
-
})
|
|
123
|
+
}).check(
|
|
124
|
+
Schema.makeFilter(
|
|
125
|
+
response => (response.status !== 204 && response.status !== 205) || response.body === "",
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
128
|
export type WebhookResponse = typeof WebhookResponse.Type;
|
|
129
129
|
export const Timestamp = Schema.String.check(
|
|
130
130
|
Schema.isMaxLength(64),
|
|
@@ -186,9 +186,7 @@ export const Echo = Schema.Struct({
|
|
|
186
186
|
messageKey: Key,
|
|
187
187
|
timestamp: Timestamp,
|
|
188
188
|
});
|
|
189
|
-
|
|
190
|
-
export type Event = typeof Event.Type;
|
|
191
|
-
/** `v2`: the sender asked the agent to stop working in this conversation. Access applies. */
|
|
189
|
+
/** The sender asked the agent to stop working in this conversation. Access applies. */
|
|
192
190
|
export const Stop = Schema.Struct({
|
|
193
191
|
...VerifiedIdentity.fields,
|
|
194
192
|
eventKey: Key,
|
|
@@ -196,10 +194,10 @@ export const Stop = Schema.Struct({
|
|
|
196
194
|
kind: Schema.Literal("stop"),
|
|
197
195
|
timestamp: Timestamp,
|
|
198
196
|
});
|
|
199
|
-
export const
|
|
200
|
-
export type
|
|
197
|
+
export const Event = Schema.Union([Message, Echo, DeliveryUpdate, Stop]);
|
|
198
|
+
export type Event = typeof Event.Type;
|
|
201
199
|
|
|
202
|
-
/** The reactions every
|
|
200
|
+
/** The reactions every provider can show. Each provider maps them to its own emoji. */
|
|
203
201
|
export const Reaction = Schema.Literals([
|
|
204
202
|
"thumbs_up",
|
|
205
203
|
"thumbs_down",
|
|
@@ -228,7 +226,7 @@ export const Plan = Schema.Struct({
|
|
|
228
226
|
});
|
|
229
227
|
export type Plan = typeof Plan.Type;
|
|
230
228
|
/**
|
|
231
|
-
* One piece of
|
|
229
|
+
* One piece of output. A `reference` is the `providerDeliveryKey` the provider returned for
|
|
232
230
|
* the message or plan it made; only that provider reads it.
|
|
233
231
|
*/
|
|
234
232
|
export const Operation = Schema.Union([
|
|
@@ -339,30 +337,6 @@ export class ChannelError extends Schema.TaggedError<ChannelError>()("AgentChann
|
|
|
339
337
|
}
|
|
340
338
|
|
|
341
339
|
const installedCommandSchema = <State extends Schema.Top>(state: State) => {
|
|
342
|
-
const operation = { extensions: Schema.optionalKey(Extensions), operationKey: Key };
|
|
343
|
-
const installed = { ...operation, installationKey: Key, state };
|
|
344
|
-
return Schema.Union([
|
|
345
|
-
Schema.Struct({
|
|
346
|
-
kind: Schema.Literal("activate"),
|
|
347
|
-
...operation,
|
|
348
|
-
ingressUrl: HttpUrl,
|
|
349
|
-
state: Schema.optionalKey(state),
|
|
350
|
-
}),
|
|
351
|
-
Schema.Struct({ kind: Schema.Literal("deactivate"), ...installed }),
|
|
352
|
-
Schema.Struct({ kind: Schema.Literal("receive"), ...installed, request: Request }),
|
|
353
|
-
Schema.Struct({
|
|
354
|
-
kind: Schema.Literal("deliver"),
|
|
355
|
-
...installed,
|
|
356
|
-
deliveryKey: Key,
|
|
357
|
-
destination: Destination,
|
|
358
|
-
content: Content,
|
|
359
|
-
/** Original responding input timestamp; retries must preserve this reference. */
|
|
360
|
-
responseToTimestamp: Schema.optionalKey(Timestamp),
|
|
361
|
-
}),
|
|
362
|
-
]);
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
const installedCommandSchemaV2 = <State extends Schema.Top>(state: State) => {
|
|
366
340
|
const operation = { extensions: Schema.optionalKey(Extensions), operationKey: Key };
|
|
367
341
|
const installed = { ...operation, installationKey: Key, state };
|
|
368
342
|
return Schema.Union([
|
|
@@ -446,60 +420,6 @@ const installedResultSchema = <State extends Schema.Top>(state: State) => {
|
|
|
446
420
|
"window_closed",
|
|
447
421
|
]),
|
|
448
422
|
}),
|
|
449
|
-
]);
|
|
450
|
-
};
|
|
451
|
-
// `v2` keeps every `v1` result except `receive`, which also carries stop events.
|
|
452
|
-
const installedResultSchemaV2 = <State extends Schema.Top>(state: State) => {
|
|
453
|
-
const operation = { extensions: Schema.optionalKey(Extensions), operationKey: Key };
|
|
454
|
-
return Schema.Union([
|
|
455
|
-
Schema.Struct({
|
|
456
|
-
kind: Schema.Literal("activate"),
|
|
457
|
-
...operation,
|
|
458
|
-
installationKey: Key,
|
|
459
|
-
state,
|
|
460
|
-
/** Durable read-only provider state that the host must persist before retrying activation. */
|
|
461
|
-
checkpoint: Schema.optionalKey(Schema.Literal(true)),
|
|
462
|
-
/** The host must observe a verified webhook handshake before cutover. */
|
|
463
|
-
verification: Schema.optionalKey(Schema.Literal("ingress")),
|
|
464
|
-
}),
|
|
465
|
-
Schema.Struct({ kind: Schema.Literal("deactivate"), ...operation }),
|
|
466
|
-
Schema.Struct({
|
|
467
|
-
kind: Schema.Literal("receive"),
|
|
468
|
-
...operation,
|
|
469
|
-
verified: Schema.Literal(true),
|
|
470
|
-
deniedEventKeys: Schema.optionalKey(Schema.Array(Key).check(Schema.isMaxLength(100))),
|
|
471
|
-
events: Schema.Array(EventV2).check(Schema.isMaxLength(100)),
|
|
472
|
-
response: Schema.optionalKey(WebhookResponse),
|
|
473
|
-
/** A provider-native setup challenge or ping proved the configured ingress. */
|
|
474
|
-
activationProof: Schema.optionalKey(Schema.Literal("verified")),
|
|
475
|
-
}),
|
|
476
|
-
Schema.Struct({
|
|
477
|
-
kind: Schema.Literal("deliver"),
|
|
478
|
-
...operation,
|
|
479
|
-
deliveryKey: Key,
|
|
480
|
-
status: Schema.Literal("succeeded"),
|
|
481
|
-
providerDeliveryKey: Key,
|
|
482
|
-
}),
|
|
483
|
-
Schema.Struct({
|
|
484
|
-
kind: Schema.Literal("deliver"),
|
|
485
|
-
...operation,
|
|
486
|
-
deliveryKey: Key,
|
|
487
|
-
status: Schema.Literal("pending"),
|
|
488
|
-
providerDeliveryKey: Key,
|
|
489
|
-
}),
|
|
490
|
-
Schema.Struct({
|
|
491
|
-
kind: Schema.Literal("deliver"),
|
|
492
|
-
...operation,
|
|
493
|
-
deliveryKey: Key,
|
|
494
|
-
status: Schema.Literal("failed"),
|
|
495
|
-
code: Schema.Literals([
|
|
496
|
-
"rejected",
|
|
497
|
-
"unauthorized",
|
|
498
|
-
"rate_limited",
|
|
499
|
-
"unavailable",
|
|
500
|
-
"window_closed",
|
|
501
|
-
]),
|
|
502
|
-
}),
|
|
503
423
|
Schema.Struct({
|
|
504
424
|
kind: Schema.Literal("read_context"),
|
|
505
425
|
...operation,
|
|
@@ -528,41 +448,35 @@ export const commandSchema = <State extends Schema.Top>(state: State) =>
|
|
|
528
448
|
Schema.Union([installedCommandSchema(state), readAssetCommand(state)]);
|
|
529
449
|
export const resultSchema = <State extends Schema.Top>(state: State) =>
|
|
530
450
|
Schema.Union([installedResultSchema(state), readAssetResult]);
|
|
531
|
-
export const commandSchemaV2 = <State extends Schema.Top>(state: State) =>
|
|
532
|
-
Schema.Union([installedCommandSchemaV2(state), readAssetCommand(state)]);
|
|
533
|
-
export const resultSchemaV2 = <State extends Schema.Top>(state: State) =>
|
|
534
|
-
Schema.Union([installedResultSchemaV2(state), readAssetResult]);
|
|
535
451
|
export type Command<State extends Schema.Top = Schema.Unknown> = ReturnType<
|
|
536
452
|
typeof commandSchema<State>
|
|
537
453
|
>["Type"];
|
|
538
454
|
export type Result<State extends Schema.Top = Schema.Unknown> = ReturnType<
|
|
539
455
|
typeof resultSchema<State>
|
|
540
456
|
>["Type"];
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
export
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
*/
|
|
565
|
-
export const CheckedResult = resultSchemaV2(Schema.Json);
|
|
457
|
+
/** Maximum UTF-8 bytes in an ordinary Channel command or result, including its JSON envelope. */
|
|
458
|
+
export const resultByteLimit = 2_097_152;
|
|
459
|
+
/** Keep the newest context messages within the checked result budget, oldest first. */
|
|
460
|
+
export function contextResult(
|
|
461
|
+
operationKey: string,
|
|
462
|
+
context: readonly ContextMessage[],
|
|
463
|
+
): Extract<Result, { readonly kind: "read_context" }> {
|
|
464
|
+
const messages: ContextMessage[] = [];
|
|
465
|
+
const result = { kind: "read_context" as const, messages, operationKey };
|
|
466
|
+
const encoder = new TextEncoder();
|
|
467
|
+
let bytes = encoder.encode(JSON.stringify(result)).byteLength;
|
|
468
|
+
for (let index = context.length - 1; index >= 0; index--) {
|
|
469
|
+
const message = context[index];
|
|
470
|
+
if (message === undefined) continue;
|
|
471
|
+
const size = encoder.encode(JSON.stringify(message)).byteLength + 1;
|
|
472
|
+
if (bytes + size > resultByteLimit) break;
|
|
473
|
+
bytes += size;
|
|
474
|
+
messages.unshift(message);
|
|
475
|
+
}
|
|
476
|
+
return result;
|
|
477
|
+
}
|
|
478
|
+
/** Encoded, JSON-safe runtime result suitable for host persistence. */
|
|
479
|
+
export const CheckedResult = resultSchema(Schema.Json);
|
|
566
480
|
export type CheckedResult = typeof CheckedResult.Type;
|
|
567
481
|
|
|
568
482
|
/** Immutable catalog projection. Live schemas remain the execution validators. */
|
|
@@ -571,10 +485,11 @@ export const Contract = Schema.Struct({
|
|
|
571
485
|
deploymentSettingsSchemaJson: Schema.Json,
|
|
572
486
|
exposure: Exposure,
|
|
573
487
|
extensionsSchemaJson: Schema.Record(Schema.String, Schema.Json),
|
|
574
|
-
featuresJson: Features
|
|
488
|
+
featuresJson: Features.check(
|
|
489
|
+
Schema.makeFilter(features => (features.operations ?? []).includes("present_outcome")),
|
|
490
|
+
),
|
|
575
491
|
operationInputSchemaJson: Schema.Json,
|
|
576
492
|
operationOutputSchemaJson: Schema.Json,
|
|
577
|
-
protocol: Schema.optionalKey(Protocol),
|
|
578
493
|
requiredChecks: RequiredChecks,
|
|
579
494
|
stateSchemaJson: Schema.Json,
|
|
580
495
|
});
|
|
@@ -586,8 +501,6 @@ export interface Definition<
|
|
|
586
501
|
State extends Schema.Top = Schema.Top,
|
|
587
502
|
Methods extends readonly AuthMethod.Any[] = readonly AuthMethod.Any[],
|
|
588
503
|
> {
|
|
589
|
-
/** Absent for the original protocol. Publish a new release to change it. */
|
|
590
|
-
readonly protocol?: Protocol;
|
|
591
504
|
readonly definitionSettings: Settings;
|
|
592
505
|
readonly deploymentSettings: Mappings;
|
|
593
506
|
readonly state: State;
|
|
@@ -604,9 +517,8 @@ export const projectContract = (
|
|
|
604
517
|
definition: Definition,
|
|
605
518
|
project: (schema: Schema.Top) => unknown = schema =>
|
|
606
519
|
Schema.toJsonSchemaDocument(schema, { onExcessProperty: "error" }),
|
|
607
|
-
): Contract =>
|
|
608
|
-
|
|
609
|
-
return Schema.decodeUnknownSync(Contract)(
|
|
520
|
+
): Contract =>
|
|
521
|
+
Schema.decodeUnknownSync(Contract)(
|
|
610
522
|
{
|
|
611
523
|
definitionSettingsSchemaJson: project(definition.definitionSettings),
|
|
612
524
|
deploymentSettingsSchemaJson: project(definition.deploymentSettings),
|
|
@@ -615,15 +527,13 @@ export const projectContract = (
|
|
|
615
527
|
Object.entries(definition.extensions ?? {}).map(([key, schema]) => [key, project(schema)]),
|
|
616
528
|
),
|
|
617
529
|
featuresJson: definition.features,
|
|
618
|
-
operationInputSchemaJson: project(
|
|
619
|
-
operationOutputSchemaJson: project(
|
|
620
|
-
...(definition.protocol === undefined ? {} : { protocol: definition.protocol }),
|
|
530
|
+
operationInputSchemaJson: project(commandSchema(definition.state)),
|
|
531
|
+
operationOutputSchemaJson: project(resultSchema(definition.state)),
|
|
621
532
|
requiredChecks: definition.requiredChecks,
|
|
622
533
|
stateSchemaJson: project(definition.state),
|
|
623
534
|
},
|
|
624
535
|
{ onExcessProperty: "error" },
|
|
625
536
|
);
|
|
626
|
-
};
|
|
627
537
|
export interface Any extends Pipeable.Pipeable {
|
|
628
538
|
readonly [TypeId]: TypeId;
|
|
629
539
|
readonly identifier: string;
|
|
@@ -652,14 +562,10 @@ export type HandlerContext<D extends Definition> = {
|
|
|
652
562
|
: number extends D["authMethods"]["length"]
|
|
653
563
|
? { readonly auth?: ResolvedAuth<D["authMethods"]> }
|
|
654
564
|
: { readonly auth: ResolvedAuth<D["authMethods"]> });
|
|
655
|
-
/** The command a Channel's handler receives
|
|
656
|
-
export type CommandFor<D extends Definition> = D
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
/** The result a Channel's handler returns, by its protocol. */
|
|
660
|
-
export type ResultFor<D extends Definition> = D extends { readonly protocol: "v2" }
|
|
661
|
-
? ResultV2<D["state"]>
|
|
662
|
-
: Result<D["state"]>;
|
|
565
|
+
/** The command a Channel's handler receives. */
|
|
566
|
+
export type CommandFor<D extends Definition> = Command<D["state"]>;
|
|
567
|
+
/** The result a Channel's handler returns. */
|
|
568
|
+
export type ResultFor<D extends Definition> = Result<D["state"]>;
|
|
663
569
|
export interface RuntimeContract<D extends Definition, R = never> {
|
|
664
570
|
readonly verify: (
|
|
665
571
|
request: Request,
|
|
@@ -761,14 +667,10 @@ const DefinitionSchema = Schema.Struct({
|
|
|
761
667
|
),
|
|
762
668
|
),
|
|
763
669
|
features: Features,
|
|
764
|
-
protocol: Schema.optionalKey(Protocol),
|
|
765
670
|
requiredChecks: RequiredChecks,
|
|
766
671
|
state: SchemaDefinition,
|
|
767
672
|
}).check(
|
|
768
|
-
Schema.makeFilter(({ features
|
|
769
|
-
if (protocol === undefined) {
|
|
770
|
-
return features.operations === undefined && features.readContext === undefined;
|
|
771
|
-
}
|
|
673
|
+
Schema.makeFilter(({ features }) => {
|
|
772
674
|
const operations = features.operations ?? [];
|
|
773
675
|
return (
|
|
774
676
|
operations.includes("present_outcome") &&
|
|
@@ -4,11 +4,7 @@ import { Effect, Schema } from "effect";
|
|
|
4
4
|
import * as AgentChannel from "./AgentChannel.ts";
|
|
5
5
|
import * as DualRuntime from "./DualRuntime.ts";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const Command = Schema.Union([
|
|
9
|
-
AgentChannel.commandSchema(Schema.Json),
|
|
10
|
-
AgentChannel.commandSchemaV2(Schema.Json),
|
|
11
|
-
]);
|
|
7
|
+
const Command = AgentChannel.commandSchema(Schema.Json);
|
|
12
8
|
export const Fixture = Schema.Struct({
|
|
13
9
|
activate: Command,
|
|
14
10
|
channelId: AgentChannel.Key,
|
|
@@ -113,7 +109,7 @@ export const run = Effect.fn("AgentChannelConformance.run")(function* (input: Fi
|
|
|
113
109
|
if (
|
|
114
110
|
first.kind !== "receive" ||
|
|
115
111
|
nextReceipt.kind !== "receive" ||
|
|
116
|
-
!Schema.toEquivalence(Schema.Array(AgentChannel.
|
|
112
|
+
!Schema.toEquivalence(Schema.Array(AgentChannel.Event))(first.events, nextReceipt.events)
|
|
117
113
|
) {
|
|
118
114
|
return yield* new ConformanceError({ command: kind, rule: "stable_events" });
|
|
119
115
|
}
|
|
@@ -105,7 +105,8 @@ const AssetResultJson = Schema.Json.check(
|
|
|
105
105
|
);
|
|
106
106
|
const Json = Schema.Json.check(
|
|
107
107
|
Schema.makeFilter(
|
|
108
|
-
value =>
|
|
108
|
+
value =>
|
|
109
|
+
new TextEncoder().encode(JSON.stringify(value)).byteLength <= AgentChannel.resultByteLimit,
|
|
109
110
|
),
|
|
110
111
|
);
|
|
111
112
|
const strict = { onExcessProperty: "error" } as const;
|
|
@@ -186,12 +187,10 @@ const checkMessage = (
|
|
|
186
187
|
|
|
187
188
|
const checkDelivery = (
|
|
188
189
|
features: AgentChannel.Features,
|
|
189
|
-
command: Extract<AgentChannel.Command
|
|
190
|
+
command: Extract<AgentChannel.Command, { kind: "deliver" }>,
|
|
190
191
|
): boolean =>
|
|
191
|
-
"
|
|
192
|
-
|
|
193
|
-
: checkMessage(features, command.destination, { text: "" }) &&
|
|
194
|
-
(features.operations ?? []).includes(command.operation.kind);
|
|
192
|
+
checkMessage(features, command.destination, { text: "" }) &&
|
|
193
|
+
(features.operations ?? []).includes(command.operation.kind);
|
|
195
194
|
|
|
196
195
|
const Material = Schema.Struct({
|
|
197
196
|
connectionId: AgentChannel.Key,
|
|
@@ -389,9 +388,8 @@ export const layer = <P extends Plugin.Any>(
|
|
|
389
388
|
request.deploymentSettings,
|
|
390
389
|
"invalid_input",
|
|
391
390
|
);
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
schemas.command,
|
|
391
|
+
const command: AgentChannel.Command = yield* decodeData(
|
|
392
|
+
AgentChannel.commandSchema(definition.state),
|
|
395
393
|
request.command,
|
|
396
394
|
"invalid_input",
|
|
397
395
|
);
|
|
@@ -404,7 +402,6 @@ export const layer = <P extends Plugin.Any>(
|
|
|
404
402
|
}
|
|
405
403
|
if (
|
|
406
404
|
command.kind === "deliver" &&
|
|
407
|
-
"operation" in command &&
|
|
408
405
|
command.operation.kind === "set_reaction" &&
|
|
409
406
|
command.operation.target.kind === "activation" &&
|
|
410
407
|
command.activationMessageKey === undefined
|
|
@@ -484,8 +481,8 @@ export const layer = <P extends Plugin.Any>(
|
|
|
484
481
|
handler.value,
|
|
485
482
|
Effect.suspend(() => handler.value.runtime.execute(command, adapterContext)),
|
|
486
483
|
);
|
|
487
|
-
const result: AgentChannel.Result
|
|
488
|
-
|
|
484
|
+
const result: AgentChannel.Result = yield* decodeData(
|
|
485
|
+
AgentChannel.resultSchema(Schema.toType(definition.state)),
|
|
489
486
|
output,
|
|
490
487
|
"invalid_result",
|
|
491
488
|
kind === "read_asset",
|
|
@@ -506,7 +503,7 @@ export const layer = <P extends Plugin.Any>(
|
|
|
506
503
|
) {
|
|
507
504
|
return yield* fail("invalid_result");
|
|
508
505
|
}
|
|
509
|
-
const allowedEvents: AgentChannel.
|
|
506
|
+
const allowedEvents: AgentChannel.Event[] = [];
|
|
510
507
|
const deniedEventKeys: string[] = [];
|
|
511
508
|
if (result.kind === "receive") {
|
|
512
509
|
if (result.deniedEventKeys !== undefined) return yield* fail("invalid_result");
|
|
@@ -562,7 +559,7 @@ export const layer = <P extends Plugin.Any>(
|
|
|
562
559
|
}
|
|
563
560
|
// Store the encoded state so subsequent pinned commands can decode it exactly once.
|
|
564
561
|
const encoded = yield* safe(
|
|
565
|
-
Schema.encodeUnknownEffect(
|
|
562
|
+
Schema.encodeUnknownEffect(AgentChannel.resultSchema(definition.state))(
|
|
566
563
|
result.kind === "receive"
|
|
567
564
|
? {
|
|
568
565
|
...result,
|