@executor-js/plugin-graphql 0.0.1-beta.6 → 0.0.1
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/group.d.ts +2 -0
- package/dist/{chunk-QEUTMVXO.js → chunk-AC5VPNLE.js} +45 -32
- package/dist/chunk-AC5VPNLE.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/sdk/operation-store.d.ts +4 -2
- package/dist/sdk/plugin.d.ts +3 -0
- package/dist/sdk/stored-source.d.ts +5 -0
- package/package.json +7 -7
- package/dist/chunk-QEUTMVXO.js.map +0 -1
package/dist/api/group.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { StoredSourceSchema } from "../sdk/stored-source";
|
|
|
4
4
|
declare const GraphqlGroup_base: HttpApiGroup.HttpApiGroup<"graphql", HttpApiEndpoint.HttpApiEndpoint<"addSource", "POST", {
|
|
5
5
|
readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
|
|
6
6
|
}, never, {
|
|
7
|
+
readonly name?: string | undefined;
|
|
7
8
|
readonly endpoint: string;
|
|
8
9
|
readonly namespace?: string | undefined;
|
|
9
10
|
readonly headers?: {
|
|
@@ -20,6 +21,7 @@ declare const GraphqlGroup_base: HttpApiGroup.HttpApiGroup<"graphql", HttpApiEnd
|
|
|
20
21
|
readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
|
|
21
22
|
readonly namespace: string;
|
|
22
23
|
}, never, {
|
|
24
|
+
readonly name?: string | undefined;
|
|
23
25
|
readonly endpoint?: string | undefined;
|
|
24
26
|
readonly headers?: {
|
|
25
27
|
readonly [x: string]: unknown;
|
|
@@ -465,7 +465,16 @@ var makeGraphqlInvoker = (opts) => ({
|
|
|
465
465
|
cause: void 0
|
|
466
466
|
});
|
|
467
467
|
}
|
|
468
|
-
const
|
|
468
|
+
const source = yield* opts.operationStore.getSource(entry.namespace);
|
|
469
|
+
if (!source) {
|
|
470
|
+
return yield* new ToolInvocationError({
|
|
471
|
+
toolId,
|
|
472
|
+
message: `No source found for namespace "${entry.namespace}"`,
|
|
473
|
+
cause: void 0
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
const { binding } = entry;
|
|
477
|
+
const { invocationConfig: config } = source;
|
|
469
478
|
const resolvedHeaders = yield* resolveHeaders(config.headers, opts.secrets, opts.scopeId);
|
|
470
479
|
const result = yield* invoke(
|
|
471
480
|
binding,
|
|
@@ -508,30 +517,40 @@ var StoredSourceSchema = class extends Schema3.Class("GraphqlStoredSource")({
|
|
|
508
517
|
introspectionJson: Schema3.optional(Schema3.String),
|
|
509
518
|
namespace: Schema3.optional(Schema3.String),
|
|
510
519
|
headers: Schema3.optional(Schema3.Record({ key: Schema3.String, value: HeaderValue }))
|
|
511
|
-
})
|
|
520
|
+
}),
|
|
521
|
+
// TODO(migration): make required once all rows have been migrated to
|
|
522
|
+
// carry invocationConfig. Left optional for decode compat with rows
|
|
523
|
+
// written before the source-level invocationConfig refactor.
|
|
524
|
+
invocationConfig: Schema3.optional(InvocationConfig)
|
|
512
525
|
}) {
|
|
513
526
|
};
|
|
514
527
|
|
|
515
528
|
// src/sdk/kv-operation-store.ts
|
|
516
529
|
var StoredEntry = class extends Schema4.Class("StoredEntry")({
|
|
517
530
|
namespace: Schema4.String,
|
|
518
|
-
binding: OperationBinding
|
|
519
|
-
config: InvocationConfig
|
|
531
|
+
binding: OperationBinding
|
|
520
532
|
}) {
|
|
521
533
|
};
|
|
522
534
|
var encodeEntry = Schema4.encodeSync(Schema4.parseJson(StoredEntry));
|
|
523
535
|
var decodeEntry = Schema4.decodeUnknownSync(Schema4.parseJson(StoredEntry));
|
|
524
536
|
var encodeSource = Schema4.encodeSync(Schema4.parseJson(StoredSourceSchema));
|
|
525
537
|
var decodeSource = Schema4.decodeUnknownSync(Schema4.parseJson(StoredSourceSchema));
|
|
538
|
+
var rehydrate = (source) => source.invocationConfig ? source : {
|
|
539
|
+
...source,
|
|
540
|
+
invocationConfig: new InvocationConfig({
|
|
541
|
+
endpoint: source.config.endpoint,
|
|
542
|
+
headers: source.config.headers ?? {}
|
|
543
|
+
})
|
|
544
|
+
};
|
|
526
545
|
var makeStore = (bindings, sources) => ({
|
|
527
546
|
get: (toolId) => Effect4.gen(function* () {
|
|
528
547
|
const raw = yield* bindings.get(toolId);
|
|
529
548
|
if (!raw) return null;
|
|
530
549
|
const entry = decodeEntry(raw);
|
|
531
|
-
return { binding: entry.binding,
|
|
550
|
+
return { binding: entry.binding, namespace: entry.namespace };
|
|
532
551
|
}),
|
|
533
|
-
put: (toolId, namespace, binding
|
|
534
|
-
{ key: toolId, value: encodeEntry(new StoredEntry({ namespace, binding
|
|
552
|
+
put: (toolId, namespace, binding) => bindings.set([
|
|
553
|
+
{ key: toolId, value: encodeEntry(new StoredEntry({ namespace, binding })) }
|
|
535
554
|
]),
|
|
536
555
|
remove: (toolId) => bindings.delete([toolId]).pipe(Effect4.asVoid),
|
|
537
556
|
listByNamespace: (namespace) => Effect4.gen(function* () {
|
|
@@ -557,12 +576,16 @@ var makeStore = (bindings, sources) => ({
|
|
|
557
576
|
removeSource: (namespace) => sources.delete([namespace]).pipe(Effect4.asVoid),
|
|
558
577
|
listSources: () => Effect4.gen(function* () {
|
|
559
578
|
const entries = yield* sources.list();
|
|
560
|
-
return entries.map((e) => decodeSource(e.value));
|
|
579
|
+
return entries.map((e) => rehydrate(decodeSource(e.value)));
|
|
561
580
|
}),
|
|
562
581
|
getSource: (namespace) => Effect4.gen(function* () {
|
|
563
582
|
const raw = yield* sources.get(namespace);
|
|
564
583
|
if (!raw) return null;
|
|
565
|
-
|
|
584
|
+
const source = decodeSource(raw);
|
|
585
|
+
if (source.invocationConfig) return source;
|
|
586
|
+
const healed = rehydrate(source);
|
|
587
|
+
yield* sources.set([{ key: namespace, value: encodeSource(healed) }]);
|
|
588
|
+
return healed;
|
|
566
589
|
}),
|
|
567
590
|
getSourceConfig: (namespace) => Effect4.gen(function* () {
|
|
568
591
|
const raw = yield* sources.get(namespace);
|
|
@@ -587,6 +610,7 @@ import {
|
|
|
587
610
|
} from "@executor-js/sdk";
|
|
588
611
|
var AddSourceInputSchema = Schema5.Struct({
|
|
589
612
|
endpoint: Schema5.String,
|
|
613
|
+
name: Schema5.optional(Schema5.String),
|
|
590
614
|
introspectionJson: Schema5.optional(Schema5.String),
|
|
591
615
|
namespace: Schema5.optional(Schema5.String),
|
|
592
616
|
headers: Schema5.optional(Schema5.Record({ key: Schema5.String, value: HeaderValue }))
|
|
@@ -687,6 +711,7 @@ var graphqlPlugin = (options) => {
|
|
|
687
711
|
id: s.namespace,
|
|
688
712
|
name: s.name,
|
|
689
713
|
kind: "graphql",
|
|
714
|
+
url: s.config.endpoint,
|
|
690
715
|
runtime: false,
|
|
691
716
|
canRemove: true,
|
|
692
717
|
canRefresh: false,
|
|
@@ -785,20 +810,21 @@ var graphqlPlugin = (options) => {
|
|
|
785
810
|
operationString,
|
|
786
811
|
variableNames: extractedField.arguments.map((a) => a.name)
|
|
787
812
|
});
|
|
788
|
-
return operationStore.put(reg.id, namespace, binding
|
|
813
|
+
return operationStore.put(reg.id, namespace, binding);
|
|
789
814
|
},
|
|
790
815
|
{ discard: true }
|
|
791
816
|
);
|
|
792
817
|
yield* ctx.tools.register(registrations);
|
|
793
818
|
yield* operationStore.putSource({
|
|
794
819
|
namespace,
|
|
795
|
-
name: namespace,
|
|
820
|
+
name: config.name?.trim() || namespace,
|
|
796
821
|
config: {
|
|
797
822
|
endpoint: config.endpoint,
|
|
798
823
|
introspectionJson: config.introspectionJson,
|
|
799
824
|
namespace: config.namespace,
|
|
800
825
|
headers: config.headers
|
|
801
|
-
}
|
|
826
|
+
},
|
|
827
|
+
invocationConfig
|
|
802
828
|
});
|
|
803
829
|
return { sourceId: namespace, toolCount: registrations.length };
|
|
804
830
|
});
|
|
@@ -841,10 +867,10 @@ var graphqlPlugin = (options) => {
|
|
|
841
867
|
}),
|
|
842
868
|
getSource: (namespace) => operationStore.getSource(namespace),
|
|
843
869
|
updateSource: (namespace, input) => Effect5.gen(function* () {
|
|
844
|
-
const
|
|
845
|
-
if (!
|
|
870
|
+
const existing = yield* operationStore.getSource(namespace);
|
|
871
|
+
if (!existing) return;
|
|
846
872
|
const updatedConfig = {
|
|
847
|
-
...
|
|
873
|
+
...existing.config,
|
|
848
874
|
...input.endpoint !== void 0 ? { endpoint: input.endpoint } : {},
|
|
849
875
|
...input.headers !== void 0 ? { headers: input.headers } : {}
|
|
850
876
|
};
|
|
@@ -852,24 +878,11 @@ var graphqlPlugin = (options) => {
|
|
|
852
878
|
endpoint: updatedConfig.endpoint,
|
|
853
879
|
headers: updatedConfig.headers ?? {}
|
|
854
880
|
});
|
|
855
|
-
const toolIds = yield* operationStore.listByNamespace(namespace);
|
|
856
|
-
for (const toolId of toolIds) {
|
|
857
|
-
const entry = yield* operationStore.get(toolId);
|
|
858
|
-
if (entry) {
|
|
859
|
-
yield* operationStore.put(
|
|
860
|
-
toolId,
|
|
861
|
-
namespace,
|
|
862
|
-
entry.binding,
|
|
863
|
-
newInvocationConfig
|
|
864
|
-
);
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
const sources = yield* operationStore.listSources();
|
|
868
|
-
const existingMeta = sources.find((s) => s.namespace === namespace);
|
|
869
881
|
yield* operationStore.putSource({
|
|
870
882
|
namespace,
|
|
871
|
-
name:
|
|
872
|
-
config: updatedConfig
|
|
883
|
+
name: input.name?.trim() || existing.name,
|
|
884
|
+
config: updatedConfig,
|
|
885
|
+
invocationConfig: newInvocationConfig
|
|
873
886
|
});
|
|
874
887
|
})
|
|
875
888
|
},
|
|
@@ -900,4 +913,4 @@ export {
|
|
|
900
913
|
makeInMemoryOperationStore,
|
|
901
914
|
graphqlPlugin
|
|
902
915
|
};
|
|
903
|
-
//# sourceMappingURL=chunk-
|
|
916
|
+
//# sourceMappingURL=chunk-AC5VPNLE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sdk/errors.ts","../src/sdk/introspect.ts","../src/sdk/types.ts","../src/sdk/extract.ts","../src/sdk/invoke.ts","../src/sdk/kv-operation-store.ts","../src/sdk/stored-source.ts","../src/sdk/plugin.ts"],"sourcesContent":["import { Data, Schema } from \"effect\";\nimport type { Option } from \"effect\";\n\nexport class GraphqlIntrospectionError extends Schema.TaggedError<GraphqlIntrospectionError>()(\n \"GraphqlIntrospectionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlExtractionError extends Schema.TaggedError<GraphqlExtractionError>()(\n \"GraphqlExtractionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlInvocationError extends Data.TaggedError(\"GraphqlInvocationError\")<{\n readonly message: string;\n readonly statusCode: Option.Option<number>;\n readonly cause?: unknown;\n}> {}\n","import { Effect } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"@effect/platform\";\n\nimport { GraphqlIntrospectionError } from \"./errors\";\n\n// ---------------------------------------------------------------------------\n// Introspection query — standard GraphQL introspection\n// ---------------------------------------------------------------------------\n\nconst INTROSPECTION_QUERY = `\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n types {\n kind\n name\n description\n fields(includeDeprecated: false) {\n name\n description\n args {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n type {\n ...TypeRef\n }\n }\n inputFields {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n enumValues(includeDeprecated: false) {\n name\n description\n }\n }\n }\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Introspection result types\n// ---------------------------------------------------------------------------\n\nexport interface IntrospectionTypeRef {\n readonly kind: string;\n readonly name: string | null;\n readonly ofType: IntrospectionTypeRef | null;\n}\n\nexport interface IntrospectionInputValue {\n readonly name: string;\n readonly description: string | null;\n readonly type: IntrospectionTypeRef;\n readonly defaultValue: string | null;\n}\n\nexport interface IntrospectionField {\n readonly name: string;\n readonly description: string | null;\n readonly args: readonly IntrospectionInputValue[];\n readonly type: IntrospectionTypeRef;\n}\n\nexport interface IntrospectionEnumValue {\n readonly name: string;\n readonly description: string | null;\n}\n\nexport interface IntrospectionType {\n readonly kind: string;\n readonly name: string;\n readonly description: string | null;\n readonly fields: readonly IntrospectionField[] | null;\n readonly inputFields: readonly IntrospectionInputValue[] | null;\n readonly enumValues: readonly IntrospectionEnumValue[] | null;\n}\n\nexport interface IntrospectionSchema {\n readonly queryType: { readonly name: string } | null;\n readonly mutationType: { readonly name: string } | null;\n readonly types: readonly IntrospectionType[];\n}\n\nexport interface IntrospectionResult {\n readonly __schema: IntrospectionSchema;\n}\n\n// ---------------------------------------------------------------------------\n// Introspect a GraphQL endpoint\n// ---------------------------------------------------------------------------\n\nexport const introspect = Effect.fn(\"GraphQL.introspect\")(function* (\n endpoint: string,\n headers?: Record<string, string>,\n) {\n const client = yield* HttpClient.HttpClient;\n\n let request = HttpClientRequest.post(endpoint).pipe(\n HttpClientRequest.setHeader(\"Content-Type\", \"application/json\"),\n HttpClientRequest.bodyUnsafeJson({\n query: INTROSPECTION_QUERY,\n }),\n );\n\n if (headers) {\n for (const [k, v] of Object.entries(headers)) {\n request = HttpClientRequest.setHeader(request, k, v);\n }\n }\n\n const response = yield* client.execute(request).pipe(\n Effect.tapErrorCause((cause) => Effect.logError(\"graphql introspection request failed\", cause)),\n Effect.mapError(\n (err) =>\n new GraphqlIntrospectionError({\n message: `Failed to reach GraphQL endpoint: ${err.message}`,\n }),\n ),\n );\n\n if (response.status !== 200) {\n return yield* new GraphqlIntrospectionError({\n message: `Introspection failed with status ${response.status}`,\n });\n }\n\n const raw = yield* response.json.pipe(\n Effect.tapErrorCause((cause) =>\n Effect.logError(\"graphql introspection JSON parse failed\", cause),\n ),\n Effect.mapError(\n () =>\n new GraphqlIntrospectionError({\n message: `Failed to parse introspection response as JSON`,\n }),\n ),\n );\n\n const json = raw as { data?: IntrospectionResult; errors?: unknown[] };\n\n if (json.errors && Array.isArray(json.errors) && json.errors.length > 0) {\n return yield* new GraphqlIntrospectionError({\n message: `Introspection returned ${json.errors.length} error(s)`,\n });\n }\n\n if (!json.data?.__schema) {\n return yield* new GraphqlIntrospectionError({\n message: \"Introspection response missing __schema\",\n });\n }\n\n return json.data;\n});\n\n// ---------------------------------------------------------------------------\n// Parse an introspection result from a JSON string (for offline/text input)\n// ---------------------------------------------------------------------------\n\nexport const parseIntrospectionJson = (\n text: string,\n): Effect.Effect<IntrospectionResult, GraphqlIntrospectionError> =>\n Effect.try({\n try: () => {\n const parsed = JSON.parse(text);\n // Accept both { data: { __schema } } and { __schema } formats\n const result = parsed.data ?? parsed;\n if (!result.__schema) {\n throw new Error(\"Missing __schema in introspection JSON\");\n }\n return result as IntrospectionResult;\n },\n catch: (err) =>\n new GraphqlIntrospectionError({\n message: `Failed to parse introspection JSON: ${err instanceof Error ? err.message : String(err)}`,\n }),\n });\n","import { Schema } from \"effect\";\n\n// ---------------------------------------------------------------------------\n// GraphQL operation kind\n// ---------------------------------------------------------------------------\n\nexport const GraphqlOperationKind = Schema.Literal(\"query\", \"mutation\");\nexport type GraphqlOperationKind = typeof GraphqlOperationKind.Type;\n\n// ---------------------------------------------------------------------------\n// Extracted field (becomes a tool)\n// ---------------------------------------------------------------------------\n\nexport class GraphqlArgument extends Schema.Class<GraphqlArgument>(\"GraphqlArgument\")({\n name: Schema.String,\n typeName: Schema.String,\n required: Schema.Boolean,\n description: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n}) {}\n\nexport class ExtractedField extends Schema.Class<ExtractedField>(\"ExtractedField\")({\n /** e.g. \"user\", \"createUser\" */\n fieldName: Schema.String,\n /** \"query\" or \"mutation\" */\n kind: GraphqlOperationKind,\n description: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n arguments: Schema.Array(GraphqlArgument),\n /** JSON Schema for the input (built from arguments) */\n inputSchema: Schema.optionalWith(Schema.Unknown, { as: \"Option\" }),\n /** The return type name for documentation */\n returnTypeName: Schema.String,\n}) {}\n\nexport class ExtractionResult extends Schema.Class<ExtractionResult>(\"ExtractionResult\")({\n /** Schema name from introspection */\n schemaName: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n fields: Schema.Array(ExtractedField),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Operation binding — minimal data needed to invoke\n// ---------------------------------------------------------------------------\n\nexport class OperationBinding extends Schema.Class<OperationBinding>(\"OperationBinding\")({\n kind: GraphqlOperationKind,\n fieldName: Schema.String,\n /** The full GraphQL query/mutation string */\n operationString: Schema.String,\n /** Ordered variable names for mapping */\n variableNames: Schema.Array(Schema.String),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Invocation\n// ---------------------------------------------------------------------------\n\nexport const HeaderValue = Schema.Union(\n Schema.String,\n Schema.Struct({\n secretId: Schema.String,\n prefix: Schema.optional(Schema.String),\n }),\n);\nexport type HeaderValue = typeof HeaderValue.Type;\n\nexport class InvocationConfig extends Schema.Class<InvocationConfig>(\"InvocationConfig\")({\n /** The GraphQL endpoint URL */\n endpoint: Schema.String,\n /** Headers applied to every request. Values can reference secrets. */\n headers: Schema.optionalWith(Schema.Record({ key: Schema.String, value: HeaderValue }), {\n default: () => ({}),\n }),\n}) {}\n\nexport class InvocationResult extends Schema.Class<InvocationResult>(\"InvocationResult\")({\n status: Schema.Number,\n data: Schema.NullOr(Schema.Unknown),\n errors: Schema.NullOr(Schema.Unknown),\n}) {}\n","import { Effect, Option } from \"effect\";\n\nimport { GraphqlExtractionError } from \"./errors\";\nimport type {\n IntrospectionResult,\n IntrospectionSchema,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionInputValue,\n} from \"./introspect\";\nimport {\n ExtractedField,\n ExtractionResult,\n GraphqlArgument,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Type ref helpers\n// ---------------------------------------------------------------------------\n\n/** Unwrap NON_NULL / LIST wrappers to get the leaf type name */\nconst unwrapTypeName = (ref: IntrospectionTypeRef): string => {\n if (ref.name) return ref.name;\n if (ref.ofType) return unwrapTypeName(ref.ofType);\n return \"Unknown\";\n};\n\n/** Check if a type ref is non-null (required) */\nconst isNonNull = (ref: IntrospectionTypeRef): boolean => ref.kind === \"NON_NULL\";\n\n// ---------------------------------------------------------------------------\n// Build shared definitions from all INPUT_OBJECT and ENUM types\n// ---------------------------------------------------------------------------\n\nconst buildDefinitions = (\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> => {\n const defs: Record<string, unknown> = {};\n\n for (const [name, type] of types) {\n // Skip internal types\n if (name.startsWith(\"__\")) continue;\n\n if (type.kind === \"INPUT_OBJECT\" && type.inputFields) {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const field of type.inputFields) {\n const schema = typeRefToJsonSchema(field.type, types);\n if (field.description) {\n (schema as Record<string, unknown>).description = field.description;\n }\n properties[field.name] = schema;\n if (isNonNull(field.type)) {\n required.push(field.name);\n }\n }\n\n const def: Record<string, unknown> = { type: \"object\", properties };\n if (required.length > 0) def.required = required;\n if (type.description) def.description = type.description;\n defs[name] = def;\n }\n\n if (type.kind === \"ENUM\" && type.enumValues) {\n defs[name] = {\n type: \"string\",\n enum: type.enumValues.map((v) => v.name),\n ...(type.description ? { description: type.description } : {}),\n };\n }\n }\n\n return defs;\n};\n\n// ---------------------------------------------------------------------------\n// Convert a type ref to JSON Schema using $ref for complex types\n// ---------------------------------------------------------------------------\n\nconst typeRefToJsonSchema = (\n ref: IntrospectionTypeRef,\n // oxlint-disable-next-line only-used-in-recursion\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? typeRefToJsonSchema(ref.ofType, types) : {};\n\n case \"LIST\":\n return {\n type: \"array\",\n items: ref.ofType ? typeRefToJsonSchema(ref.ofType, types) : {},\n };\n\n case \"SCALAR\":\n return scalarToJsonSchema(ref.name ?? \"String\");\n\n case \"ENUM\":\n // Reference the shared definition\n return ref.name ? { $ref: `#/$defs/${ref.name}` } : { type: \"string\" };\n\n case \"INPUT_OBJECT\":\n // Reference the shared definition — no recursive expansion needed\n return ref.name ? { $ref: `#/$defs/${ref.name}` } : { type: \"object\" };\n\n case \"OBJECT\":\n case \"INTERFACE\":\n case \"UNION\":\n return { type: \"object\" };\n\n default:\n return {};\n }\n};\n\nconst scalarToJsonSchema = (name: string): Record<string, unknown> => {\n switch (name) {\n case \"String\":\n case \"ID\":\n return { type: \"string\" };\n case \"Int\":\n return { type: \"integer\" };\n case \"Float\":\n return { type: \"number\" };\n case \"Boolean\":\n return { type: \"boolean\" };\n default:\n return { type: \"string\", description: `Custom scalar: ${name}` };\n }\n};\n\n// ---------------------------------------------------------------------------\n// Build input JSON Schema from field arguments\n// ---------------------------------------------------------------------------\n\nconst buildInputSchema = (\n args: readonly IntrospectionInputValue[],\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> | undefined => {\n if (args.length === 0) return undefined;\n\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const arg of args) {\n const schema = typeRefToJsonSchema(arg.type, types);\n if (arg.description) {\n (schema as Record<string, unknown>).description = arg.description;\n }\n properties[arg.name] = schema;\n if (isNonNull(arg.type)) {\n required.push(arg.name);\n }\n }\n\n const inputSchema: Record<string, unknown> = {\n type: \"object\",\n properties,\n };\n if (required.length > 0) inputSchema.required = required;\n return inputSchema;\n};\n\n/** Format a type ref back to GraphQL type notation (e.g. \"[String!]!\") */\nconst formatTypeRef = (ref: IntrospectionTypeRef): string => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? `${formatTypeRef(ref.ofType)}!` : \"Unknown!\";\n case \"LIST\":\n return ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : \"[Unknown]\";\n default:\n return ref.name ?? \"Unknown\";\n }\n};\n\n// ---------------------------------------------------------------------------\n// Extract fields from schema\n// ---------------------------------------------------------------------------\n\nconst extractFields = (\n _schema: IntrospectionSchema,\n kind: GraphqlOperationKind,\n typeName: string | null | undefined,\n types: ReadonlyMap<string, IntrospectionType>,\n): ExtractedField[] => {\n if (!typeName) return [];\n\n const type = types.get(typeName);\n if (!type?.fields) return [];\n\n return type.fields\n .filter((f) => !f.name.startsWith(\"__\"))\n .map((field) => {\n const args = field.args.map(\n (arg) =>\n new GraphqlArgument({\n name: arg.name,\n typeName: formatTypeRef(arg.type),\n required: isNonNull(arg.type),\n description: arg.description ? Option.some(arg.description) : Option.none(),\n }),\n );\n\n const inputSchema = buildInputSchema(field.args, types);\n\n return new ExtractedField({\n fieldName: field.name,\n kind,\n description: field.description ? Option.some(field.description) : Option.none(),\n arguments: args,\n inputSchema: inputSchema ? Option.some(inputSchema) : Option.none(),\n returnTypeName: unwrapTypeName(field.type),\n });\n });\n};\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\nexport interface ExtractionOutput {\n readonly result: ExtractionResult;\n /** Shared JSON Schema definitions for INPUT_OBJECT and ENUM types.\n * Tool input schemas use `$ref` pointers into these. */\n readonly definitions: Record<string, unknown>;\n}\n\nexport const extract = (\n introspection: IntrospectionResult,\n): Effect.Effect<ExtractionOutput, GraphqlExtractionError> =>\n Effect.try({\n try: () => {\n const schema = introspection.__schema;\n const typeMap = new Map<string, IntrospectionType>();\n for (const t of schema.types) {\n typeMap.set(t.name, t);\n }\n\n const definitions = buildDefinitions(typeMap);\n\n const queryFields = extractFields(schema, \"query\", schema.queryType?.name, typeMap);\n const mutationFields = extractFields(schema, \"mutation\", schema.mutationType?.name, typeMap);\n\n return {\n result: new ExtractionResult({\n schemaName: Option.none(),\n fields: [...queryFields, ...mutationFields],\n }),\n definitions,\n };\n },\n catch: (err) =>\n new GraphqlExtractionError({\n message: `Failed to extract GraphQL schema: ${err instanceof Error ? err.message : String(err)}`,\n }),\n });\n","import { Effect, Layer, Option } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"@effect/platform\";\n\nimport {\n type ToolId,\n type ToolInvoker,\n ToolInvocationResult,\n ToolInvocationError,\n type ScopeId,\n type SecretId,\n} from \"@executor/sdk\";\n\nimport { GraphqlInvocationError } from \"./errors\";\nimport type { GraphqlOperationStore } from \"./operation-store\";\nimport {\n type HeaderValue,\n type OperationBinding,\n InvocationConfig,\n InvocationResult,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Header resolution — resolves secret refs at invocation time\n// ---------------------------------------------------------------------------\n\nconst resolveHeaders = (\n headers: Record<string, HeaderValue>,\n secrets: {\n readonly resolve: (secretId: SecretId, scopeId: ScopeId) => Effect.Effect<string, unknown>;\n },\n scopeId: ScopeId,\n): Effect.Effect<Record<string, string>, ToolInvocationError> =>\n Effect.gen(function* () {\n const resolved: Record<string, string> = {};\n for (const [name, value] of Object.entries(headers)) {\n if (typeof value === \"string\") {\n resolved[name] = value;\n } else {\n const secret = yield* secrets.resolve(value.secretId as SecretId, scopeId).pipe(\n Effect.mapError(\n () =>\n new ToolInvocationError({\n toolId: \"\" as ToolId,\n message: `Failed to resolve secret \"${value.secretId}\" for header \"${name}\"`,\n cause: undefined,\n }),\n ),\n );\n resolved[name] = value.prefix ? `${value.prefix}${secret}` : secret;\n }\n }\n return resolved;\n });\n\n// ---------------------------------------------------------------------------\n// Response helpers\n// ---------------------------------------------------------------------------\n\nconst isJsonContentType = (ct: string | null | undefined): boolean => {\n if (!ct) return false;\n const normalized = ct.split(\";\")[0]?.trim().toLowerCase() ?? \"\";\n return (\n normalized === \"application/json\" || normalized.includes(\"+json\") || normalized.includes(\"json\")\n );\n};\n\n// ---------------------------------------------------------------------------\n// Public API — execute a GraphQL operation\n// ---------------------------------------------------------------------------\n\nexport const invoke = Effect.fn(\"GraphQL.invoke\")(function* (\n operation: OperationBinding,\n args: Record<string, unknown>,\n config: InvocationConfig,\n resolvedHeaders?: Record<string, string>,\n) {\n const client = yield* HttpClient.HttpClient;\n\n // Build the GraphQL request body\n const variables: Record<string, unknown> = {};\n for (const varName of operation.variableNames) {\n if (args[varName] !== undefined) {\n variables[varName] = args[varName];\n }\n }\n\n // Also pick up any variables from a \"variables\" container\n if (typeof args.variables === \"object\" && args.variables !== null) {\n Object.assign(variables, args.variables);\n }\n\n let request = HttpClientRequest.post(config.endpoint).pipe(\n HttpClientRequest.setHeader(\"Content-Type\", \"application/json\"),\n HttpClientRequest.bodyUnsafeJson({\n query: operation.operationString,\n variables: Object.keys(variables).length > 0 ? variables : undefined,\n }),\n );\n\n // Apply resolved headers\n if (resolvedHeaders) {\n for (const [name, value] of Object.entries(resolvedHeaders)) {\n request = HttpClientRequest.setHeader(request, name, value);\n }\n }\n\n const response = yield* client.execute(request).pipe(\n Effect.mapError(\n (err) =>\n new GraphqlInvocationError({\n message: `GraphQL request failed: ${err.message}`,\n statusCode: Option.none(),\n cause: err,\n }),\n ),\n );\n\n const status = response.status;\n const contentType = response.headers[\"content-type\"] ?? null;\n\n const body: unknown = isJsonContentType(contentType)\n ? yield* response.json.pipe(Effect.catchAll(() => response.text))\n : yield* response.text;\n\n // GraphQL responses are always 200 with { data, errors }\n const gqlBody = body as { data?: unknown; errors?: unknown[] } | null;\n const hasErrors = Array.isArray(gqlBody?.errors) && gqlBody.errors.length > 0;\n\n return new InvocationResult({\n status,\n data: gqlBody?.data ?? null,\n errors: hasErrors ? gqlBody!.errors : null,\n });\n});\n\n// ---------------------------------------------------------------------------\n// ToolInvoker — bridges operation store + HTTP client into SDK invoker\n// ---------------------------------------------------------------------------\n\nexport const makeGraphqlInvoker = (opts: {\n readonly operationStore: GraphqlOperationStore;\n readonly httpClientLayer: Layer.Layer<HttpClient.HttpClient>;\n readonly secrets: {\n readonly resolve: (secretId: SecretId, scopeId: ScopeId) => Effect.Effect<string, unknown>;\n };\n readonly scopeId: ScopeId;\n}): ToolInvoker => ({\n resolveAnnotations: (toolId: ToolId) =>\n Effect.gen(function* () {\n const entry = yield* opts.operationStore.get(toolId);\n if (!entry) return undefined;\n // Mutations require approval, queries don't\n if (entry.binding.kind === \"mutation\") {\n return {\n requiresApproval: true,\n approvalDescription: `mutation ${entry.binding.fieldName}`,\n };\n }\n return {};\n }),\n\n invoke: (toolId: ToolId, args: unknown) =>\n Effect.gen(function* () {\n const entry = yield* opts.operationStore.get(toolId);\n if (!entry) {\n return yield* new ToolInvocationError({\n toolId,\n message: `No GraphQL operation found for tool \"${toolId}\"`,\n cause: undefined,\n });\n }\n\n const source = yield* opts.operationStore.getSource(entry.namespace);\n if (!source) {\n return yield* new ToolInvocationError({\n toolId,\n message: `No source found for namespace \"${entry.namespace}\"`,\n cause: undefined,\n });\n }\n\n const { binding } = entry;\n const { invocationConfig: config } = source;\n\n // Resolve secret-backed headers\n const resolvedHeaders = yield* resolveHeaders(config.headers, opts.secrets, opts.scopeId);\n\n const result = yield* invoke(\n binding,\n (args ?? {}) as Record<string, unknown>,\n config,\n resolvedHeaders,\n ).pipe(Effect.provide(opts.httpClientLayer));\n\n return new ToolInvocationResult({\n data: result.data,\n error: result.errors,\n status: result.status,\n });\n }).pipe(\n Effect.catchAll((err) => {\n if (\n typeof err === \"object\" &&\n err !== null &&\n \"_tag\" in err &&\n (err as { _tag: string })._tag === \"ToolInvocationError\"\n ) {\n return Effect.fail(err as ToolInvocationError);\n }\n return Effect.fail(\n new ToolInvocationError({\n toolId,\n message: `GraphQL invocation failed: ${err instanceof Error ? err.message : String(err)}`,\n cause: err,\n }),\n );\n }),\n ),\n});\n","// ---------------------------------------------------------------------------\n// KV-backed GraphqlOperationStore\n// ---------------------------------------------------------------------------\n\nimport { Effect, Schema } from \"effect\";\nimport { scopeKv, makeInMemoryScopedKv, type Kv, type ToolId, type ScopedKv } from \"@executor/sdk\";\n\nimport type { GraphqlOperationStore, StoredSource } from \"./operation-store\";\nimport { InvocationConfig, OperationBinding } from \"./types\";\nimport { StoredSourceSchema } from \"./stored-source\";\n\n// ---------------------------------------------------------------------------\n// Stored schemas\n// ---------------------------------------------------------------------------\n\nclass StoredEntry extends Schema.Class<StoredEntry>(\"StoredEntry\")({\n namespace: Schema.String,\n binding: OperationBinding,\n}) {}\n\nconst encodeEntry = Schema.encodeSync(Schema.parseJson(StoredEntry));\nconst decodeEntry = Schema.decodeUnknownSync(Schema.parseJson(StoredEntry));\n\nconst encodeSource = Schema.encodeSync(Schema.parseJson(StoredSourceSchema));\nconst decodeSource = Schema.decodeUnknownSync(Schema.parseJson(StoredSourceSchema));\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n// TODO(migration): remove DecodedSource + rehydrate once all source rows\n// have been migrated to carry invocationConfig. For GraphQL the endpoint\n// is always user-provided in SourceConfig, so rehydration is lossless.\ntype DecodedSource = Omit<StoredSource, \"invocationConfig\"> & {\n invocationConfig?: InvocationConfig;\n};\n\nconst rehydrate = (source: DecodedSource): StoredSource =>\n source.invocationConfig\n ? (source as StoredSource)\n : {\n ...source,\n invocationConfig: new InvocationConfig({\n endpoint: source.config.endpoint,\n headers: source.config.headers ?? {},\n }),\n };\n\nconst makeStore = (bindings: ScopedKv, sources: ScopedKv): GraphqlOperationStore => ({\n get: (toolId) =>\n Effect.gen(function* () {\n const raw = yield* bindings.get(toolId);\n if (!raw) return null;\n const entry = decodeEntry(raw);\n return { binding: entry.binding, namespace: entry.namespace };\n }),\n\n put: (toolId, namespace, binding) =>\n bindings.set([\n { key: toolId, value: encodeEntry(new StoredEntry({ namespace, binding })) },\n ]),\n\n remove: (toolId) => bindings.delete([toolId]).pipe(Effect.asVoid),\n\n listByNamespace: (namespace) =>\n Effect.gen(function* () {\n const entries = yield* bindings.list();\n const ids: ToolId[] = [];\n for (const e of entries) {\n const entry = decodeEntry(e.value);\n if (entry.namespace === namespace) ids.push(e.key as ToolId);\n }\n return ids;\n }),\n\n removeByNamespace: (namespace) =>\n Effect.gen(function* () {\n const entries = yield* bindings.list();\n const ids: ToolId[] = [];\n for (const e of entries) {\n const entry = decodeEntry(e.value);\n if (entry.namespace === namespace) ids.push(e.key as ToolId);\n }\n if (ids.length > 0) yield* bindings.delete(ids);\n return ids;\n }),\n\n putSource: (source) => sources.set([{ key: source.namespace, value: encodeSource(source) }]),\n\n removeSource: (namespace) => sources.delete([namespace]).pipe(Effect.asVoid),\n\n listSources: () =>\n Effect.gen(function* () {\n const entries = yield* sources.list();\n // TODO(migration): rehydrate in memory only — avoid N writes per list.\n return entries.map((e) => rehydrate(decodeSource(e.value) as DecodedSource));\n }),\n\n getSource: (namespace) =>\n Effect.gen(function* () {\n const raw = yield* sources.get(namespace);\n if (!raw) return null;\n const source = decodeSource(raw) as DecodedSource;\n if (source.invocationConfig) return source as StoredSource;\n // TODO(migration): self-heal — rehydrate and write back once.\n const healed = rehydrate(source);\n yield* sources.set([{ key: namespace, value: encodeSource(healed) }]);\n return healed;\n }),\n\n getSourceConfig: (namespace) =>\n Effect.gen(function* () {\n const raw = yield* sources.get(namespace);\n if (!raw) return null;\n const source = decodeSource(raw) as StoredSource;\n return source.config;\n }),\n});\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nexport const makeKvOperationStore = (kv: Kv, namespace: string): GraphqlOperationStore =>\n makeStore(scopeKv(kv, `${namespace}.bindings`), scopeKv(kv, `${namespace}.sources`));\n\nexport const makeInMemoryOperationStore = (): GraphqlOperationStore =>\n makeStore(makeInMemoryScopedKv(), makeInMemoryScopedKv());\n","import { Schema } from \"effect\";\n\nimport { HeaderValue, InvocationConfig } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Stored source — the shape persisted by the operation store and exposed\n// via the getSource HTTP endpoint.\n// ---------------------------------------------------------------------------\n\nexport class StoredSourceSchema extends Schema.Class<StoredSourceSchema>(\"GraphqlStoredSource\")({\n namespace: Schema.String,\n name: Schema.String,\n config: Schema.Struct({\n endpoint: Schema.String,\n introspectionJson: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record({ key: Schema.String, value: HeaderValue })),\n }),\n // TODO(migration): make required once all rows have been migrated to\n // carry invocationConfig. Left optional for decode compat with rows\n // written before the source-level invocationConfig refactor.\n invocationConfig: Schema.optional(InvocationConfig),\n}) {}\n\nexport type StoredSourceSchemaType = typeof StoredSourceSchema.Type;\n","import { Effect, Option, Schema } from \"effect\";\nimport { FetchHttpClient, HttpClient } from \"@effect/platform\";\nimport type { Layer } from \"effect\";\n\nimport {\n Source,\n SourceDetectionResult,\n definePlugin,\n registerRuntimeTools,\n runtimeTool,\n type ExecutorPlugin,\n type PluginContext,\n ToolId,\n type SecretId,\n type ToolRegistration,\n} from \"@executor/sdk\";\n\nimport {\n introspect,\n parseIntrospectionJson,\n type IntrospectionResult,\n type IntrospectionType,\n type IntrospectionField,\n} from \"./introspect\";\nimport { extract } from \"./extract\";\nimport { GraphqlExtractionError } from \"./errors\";\nimport { makeGraphqlInvoker } from \"./invoke\";\nimport type { GraphqlOperationStore, StoredSource } from \"./operation-store\";\nimport { makeInMemoryOperationStore } from \"./kv-operation-store\";\nimport {\n ExtractedField,\n HeaderValue as HeaderValueSchema,\n InvocationConfig,\n OperationBinding,\n type HeaderValue as HeaderValueValue,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Plugin config\n// ---------------------------------------------------------------------------\n\nexport type HeaderValue = HeaderValueValue;\n\nexport interface GraphqlSourceConfig {\n /** The GraphQL endpoint URL */\n readonly endpoint: string;\n /** Display name for the source. Falls back to namespace if not provided. */\n readonly name?: string;\n /** Optional: introspection JSON text (if endpoint doesn't support introspection) */\n readonly introspectionJson?: string;\n /** Namespace for the tools (derived from endpoint if not provided) */\n readonly namespace?: string;\n /** Headers applied to every request. Values can reference secrets. */\n readonly headers?: Record<string, HeaderValue>;\n}\n\n// ---------------------------------------------------------------------------\n// Plugin extension\n// ---------------------------------------------------------------------------\n\nexport interface GraphqlUpdateSourceInput {\n readonly name?: string;\n readonly endpoint?: string;\n readonly headers?: Record<string, HeaderValue>;\n}\n\nexport interface GraphqlPluginExtension {\n /** Add a GraphQL endpoint and register its operations as tools */\n readonly addSource: (\n config: GraphqlSourceConfig,\n ) => Effect.Effect<{ readonly toolCount: number }, Error>;\n\n /** Remove all tools from a previously added GraphQL source by namespace */\n readonly removeSource: (namespace: string) => Effect.Effect<void>;\n\n /** Fetch the full stored source by namespace (or null if missing) */\n readonly getSource: (namespace: string) => Effect.Effect<StoredSource | null>;\n\n /** Update config (endpoint, headers) for an existing GraphQL source */\n readonly updateSource: (\n namespace: string,\n input: GraphqlUpdateSourceInput,\n ) => Effect.Effect<void>;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst AddSourceInputSchema = Schema.Struct({\n endpoint: Schema.String,\n name: Schema.optional(Schema.String),\n introspectionJson: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record({ key: Schema.String, value: HeaderValueSchema })),\n});\ntype AddSourceInput = typeof AddSourceInputSchema.Type;\n\nconst AddSourceOutputSchema = Schema.Struct({\n sourceId: Schema.String,\n toolCount: Schema.Number,\n});\n\n/** Derive a namespace from an endpoint URL */\nconst namespaceFromEndpoint = (endpoint: string): string => {\n try {\n const url = new URL(endpoint);\n return url.hostname.replace(/[^a-z0-9]+/gi, \"_\").toLowerCase();\n } catch {\n return \"graphql\";\n }\n};\n\nconst buildOperationStringForField = (\n kind: GraphqlOperationKind,\n field: IntrospectionField,\n types: ReadonlyMap<string, IntrospectionType>,\n): string => {\n const opType = kind === \"query\" ? \"query\" : \"mutation\";\n\n const varDefs = field.args.map((arg) => {\n const typeName = formatTypeRef(arg.type);\n return `$${arg.name}: ${typeName}`;\n });\n\n const argPasses = field.args.map((arg) => `${arg.name}: $${arg.name}`);\n const selectionSet = buildSelectionSet(field.type, types, 0, new Set());\n\n const varDefsStr = varDefs.length > 0 ? `(${varDefs.join(\", \")})` : \"\";\n const argPassStr = argPasses.length > 0 ? `(${argPasses.join(\", \")})` : \"\";\n\n return `${opType}${varDefsStr} { ${field.name}${argPassStr}${selectionSet ? ` ${selectionSet}` : \"\"} }`;\n};\n\nimport type { IntrospectionTypeRef } from \"./introspect\";\n\nconst formatTypeRef = (ref: IntrospectionTypeRef): string => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? `${formatTypeRef(ref.ofType)}!` : \"Unknown!\";\n case \"LIST\":\n return ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : \"[Unknown]\";\n default:\n return ref.name ?? \"Unknown\";\n }\n};\n\nconst unwrapTypeName = (ref: IntrospectionTypeRef): string => {\n if (ref.name) return ref.name;\n if (ref.ofType) return unwrapTypeName(ref.ofType);\n return \"Unknown\";\n};\n\nconst buildSelectionSet = (\n ref: IntrospectionTypeRef,\n types: ReadonlyMap<string, IntrospectionType>,\n depth: number,\n seen: Set<string>,\n): string => {\n if (depth > 2) return \"\";\n\n const leafName = unwrapTypeName(ref);\n if (seen.has(leafName)) return \"\";\n\n const objectType = types.get(leafName);\n if (!objectType?.fields) return \"\";\n\n const kind = objectType.kind;\n if (kind === \"SCALAR\" || kind === \"ENUM\") return \"\";\n\n seen.add(leafName);\n\n const subFields = objectType.fields\n .filter((f) => !f.name.startsWith(\"__\"))\n .slice(0, 12)\n .map((f) => {\n const sub = buildSelectionSet(f.type, types, depth + 1, seen);\n return sub ? `${f.name} ${sub}` : f.name;\n });\n\n seen.delete(leafName);\n\n return subFields.length > 0 ? `{ ${subFields.join(\" \")} }` : \"\";\n};\n\nconst toRegistration = (field: ExtractedField, namespace: string): ToolRegistration => {\n const prefix = field.kind === \"mutation\" ? \"mutation\" : \"query\";\n const toolPath = `${prefix}.${field.fieldName}`;\n const description = Option.getOrElse(\n field.description,\n () => `GraphQL ${field.kind}: ${field.fieldName} -> ${field.returnTypeName}`,\n );\n\n return {\n id: ToolId.make(`${namespace}.${toolPath}`),\n pluginKey: \"graphql\",\n sourceId: namespace,\n name: toolPath,\n description,\n inputSchema: Option.getOrUndefined(field.inputSchema),\n outputSchema: undefined,\n };\n};\n\n// ---------------------------------------------------------------------------\n// Plugin factory\n// ---------------------------------------------------------------------------\n\nexport const graphqlPlugin = (options?: {\n readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient>;\n readonly operationStore?: GraphqlOperationStore;\n}): ExecutorPlugin<\"graphql\", GraphqlPluginExtension> => {\n const httpClientLayer = options?.httpClientLayer ?? FetchHttpClient.layer;\n const operationStore = options?.operationStore ?? makeInMemoryOperationStore();\n\n return definePlugin({\n key: \"graphql\",\n init: (ctx: PluginContext) =>\n Effect.gen(function* () {\n yield* ctx.tools.registerInvoker(\n \"graphql\",\n makeGraphqlInvoker({\n operationStore,\n httpClientLayer,\n secrets: ctx.secrets,\n scopeId: ctx.scope.id,\n }),\n );\n\n yield* ctx.sources.addManager({\n kind: \"graphql\",\n\n list: () =>\n operationStore.listSources().pipe(\n Effect.map((metas) =>\n metas.map(\n (s) =>\n new Source({\n id: s.namespace,\n name: s.name,\n kind: \"graphql\",\n url: s.config.endpoint,\n runtime: false,\n canRemove: true,\n canRefresh: false,\n canEdit: true,\n }),\n ),\n ),\n ),\n\n remove: (sourceId: string) =>\n Effect.gen(function* () {\n yield* operationStore.removeByNamespace(sourceId);\n yield* operationStore.removeSource(sourceId);\n yield* ctx.tools.unregisterBySource(sourceId);\n }),\n\n detect: (url: string) =>\n Effect.gen(function* () {\n const trimmed = url.trim();\n if (!trimmed) return null;\n const parsed = yield* Effect.try(() => new URL(trimmed)).pipe(Effect.option);\n if (parsed._tag === \"None\") return null;\n\n const ok = yield* introspect(trimmed).pipe(\n Effect.provide(httpClientLayer),\n Effect.map(() => true),\n Effect.catchAll(() => Effect.succeed(false)),\n );\n\n if (!ok) return null;\n\n const name = namespaceFromEndpoint(trimmed);\n return new SourceDetectionResult({\n kind: \"graphql\",\n confidence: \"high\",\n endpoint: trimmed,\n name,\n namespace: name,\n });\n }),\n });\n\n const addSourceInternal = (config: GraphqlSourceConfig) =>\n Effect.gen(function* () {\n // Get introspection result — either by querying the endpoint or parsing provided JSON\n let introspectionResult: IntrospectionResult;\n if (config.introspectionJson) {\n introspectionResult = yield* parseIntrospectionJson(config.introspectionJson);\n } else {\n // Resolve all headers (including secret refs) for introspection\n const resolvedHeaders: Record<string, string> = {};\n if (config.headers) {\n for (const [name, value] of Object.entries(config.headers)) {\n if (typeof value === \"string\") {\n resolvedHeaders[name] = value;\n } else {\n const secret = yield* ctx.secrets\n .resolve(value.secretId as SecretId, ctx.scope.id)\n .pipe(Effect.catchAll(() => Effect.succeed(\"\")));\n if (secret) {\n resolvedHeaders[name] = value.prefix ? `${value.prefix}${secret}` : secret;\n }\n }\n }\n }\n\n introspectionResult = yield* introspect(\n config.endpoint,\n Object.keys(resolvedHeaders).length > 0 ? resolvedHeaders : undefined,\n ).pipe(Effect.provide(httpClientLayer));\n }\n\n const { result, definitions } = yield* extract(introspectionResult);\n const namespace = config.namespace ?? namespaceFromEndpoint(config.endpoint);\n\n // Register shared JSON Schema definitions ($ref targets)\n if (Object.keys(definitions).length > 0) {\n yield* ctx.tools.registerDefinitions(definitions);\n }\n\n const invocationConfig = new InvocationConfig({\n endpoint: config.endpoint,\n headers: config.headers ?? {},\n });\n\n // Build type map for operation string generation\n const typeMap = new Map<string, IntrospectionType>();\n for (const t of introspectionResult.__schema.types) {\n typeMap.set(t.name, t);\n }\n\n // Build field map for operation strings\n const fieldMap = new Map<\n string,\n { kind: GraphqlOperationKind; field: IntrospectionField }\n >();\n const schema = introspectionResult.__schema;\n\n for (const rootKind of [\"query\", \"mutation\"] as const) {\n const typeName =\n rootKind === \"query\" ? schema.queryType?.name : schema.mutationType?.name;\n if (!typeName) continue;\n const rootType = typeMap.get(typeName);\n if (!rootType?.fields) continue;\n for (const f of rootType.fields) {\n if (!f.name.startsWith(\"__\")) {\n fieldMap.set(`${rootKind}.${f.name}`, { kind: rootKind, field: f });\n }\n }\n }\n\n const registrations: ToolRegistration[] = [];\n\n yield* Effect.forEach(\n result.fields,\n (extractedField) => {\n const reg = toRegistration(extractedField, namespace);\n registrations.push(reg);\n\n const key = `${extractedField.kind}.${extractedField.fieldName}`;\n const entry = fieldMap.get(key);\n\n const operationString = entry\n ? buildOperationStringForField(entry.kind, entry.field, typeMap)\n : `${extractedField.kind} { ${extractedField.fieldName} }`;\n\n const binding = new OperationBinding({\n kind: extractedField.kind,\n fieldName: extractedField.fieldName,\n operationString,\n variableNames: extractedField.arguments.map((a) => a.name),\n });\n\n return operationStore.put(reg.id, namespace, binding);\n },\n { discard: true },\n );\n\n yield* ctx.tools.register(registrations);\n\n yield* operationStore.putSource({\n namespace,\n name: config.name?.trim() || namespace,\n config: {\n endpoint: config.endpoint,\n introspectionJson: config.introspectionJson,\n namespace: config.namespace,\n headers: config.headers,\n },\n invocationConfig,\n });\n\n return { sourceId: namespace, toolCount: registrations.length };\n });\n\n const runtimeTools = yield* registerRuntimeTools({\n registry: ctx.tools,\n sources: ctx.sources,\n pluginKey: \"graphql\",\n source: {\n id: \"built-in\",\n name: \"Built In\",\n kind: \"built-in\",\n },\n tools: [\n runtimeTool({\n id: \"graphql.addSource\",\n name: \"graphql.addSource\",\n description: \"Add a GraphQL endpoint and register its operations as tools\",\n inputSchema: AddSourceInputSchema,\n outputSchema: AddSourceOutputSchema,\n handler: (input: AddSourceInput) => addSourceInternal(input),\n }),\n ],\n });\n\n return {\n extension: {\n addSource: (config: GraphqlSourceConfig) =>\n addSourceInternal(config).pipe(\n Effect.map(({ toolCount }) => ({ toolCount })),\n Effect.mapError(\n (err) =>\n new GraphqlExtractionError({\n message: err instanceof Error ? err.message : String(err),\n }),\n ),\n ),\n\n removeSource: (namespace: string) =>\n Effect.gen(function* () {\n const toolIds = yield* operationStore.removeByNamespace(namespace);\n if (toolIds.length > 0) {\n yield* ctx.tools.unregister(toolIds);\n }\n yield* operationStore.removeSource(namespace);\n }),\n\n getSource: (namespace: string) => operationStore.getSource(namespace),\n\n updateSource: (namespace: string, input: GraphqlUpdateSourceInput) =>\n Effect.gen(function* () {\n const existing = yield* operationStore.getSource(namespace);\n if (!existing) return;\n\n const updatedConfig = {\n ...existing.config,\n ...(input.endpoint !== undefined ? { endpoint: input.endpoint } : {}),\n ...(input.headers !== undefined\n ? { headers: input.headers as Record<string, HeaderValueValue> }\n : {}),\n };\n\n const newInvocationConfig = new InvocationConfig({\n endpoint: updatedConfig.endpoint,\n headers: (updatedConfig.headers ?? {}) as Record<string, HeaderValueValue>,\n });\n\n yield* operationStore.putSource({\n namespace,\n name: input.name?.trim() || existing.name,\n config: updatedConfig,\n invocationConfig: newInvocationConfig,\n });\n }),\n },\n\n close: () => runtimeTools.close(),\n };\n }),\n });\n};\n"],"mappings":";AAAA,SAAS,MAAM,cAAc;AAGtB,IAAM,4BAAN,cAAwC,OAAO,YAAuC;AAAA,EAC3F;AAAA,EACA;AAAA,IACE,SAAS,OAAO;AAAA,EAClB;AACF,EAAE;AAAC;AAEI,IAAM,yBAAN,cAAqC,OAAO,YAAoC;AAAA,EACrF;AAAA,EACA;AAAA,IACE,SAAS,OAAO;AAAA,EAClB;AACF,EAAE;AAAC;AAEI,IAAM,yBAAN,cAAqC,KAAK,YAAY,wBAAwB,EAIlF;AAAC;;;ACrBJ,SAAS,cAAc;AACvB,SAAS,YAAY,yBAAyB;AAQ9C,IAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0HrB,IAAM,aAAa,OAAO,GAAG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M,gBAAgB;AAAA,cACpB,GAAG,SAAS;AAAA,cACZ,GAAI,MAAM,aAAa,SAAY,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;AAAA,cACnE,GAAI,MAAM,YAAY,SAClB,EAAE,SAAS,MAAM,QAA4C,IAC7D,CAAC;AAAA,YACP;AAEA,kBAAM,sBAAsB,IAAI,iBAAiB;AAAA,cAC/C,UAAU,cAAc;AAAA,cACxB,SAAU,cAAc,WAAW,CAAC;AAAA,YACtC,CAAC;AAED,mBAAO,eAAe,UAAU;AAAA,cAC9B;AAAA,cACA,MAAM,MAAM,MAAM,KAAK,KAAK,SAAS;AAAA,cACrC,QAAQ;AAAA,cACR,kBAAkB;AAAA,YACpB,CAAC;AAAA,UACH,CAAC;AAAA,QACL;AAAA,QAEA,OAAO,MAAM,aAAa,MAAM;AAAA,MAClC;AAAA,IACF,CAAC;AAAA,EACL,CAAC;AACH;","names":["Schema","Effect","Effect","Effect","Option","HttpClient","HttpClientRequest","Effect","HttpClient","HttpClientRequest","Option","Effect","Schema","Schema","Schema","Schema","Effect","Effect","Option","Schema","Schema","formatTypeRef","unwrapTypeName","Option","Effect"]}
|
package/dist/core.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -11,13 +11,15 @@ export interface StoredSource {
|
|
|
11
11
|
readonly namespace: string;
|
|
12
12
|
readonly name: string;
|
|
13
13
|
readonly config: SourceConfig;
|
|
14
|
+
/** Pre-resolved runtime invocation config (endpoint, headers). */
|
|
15
|
+
readonly invocationConfig: InvocationConfig;
|
|
14
16
|
}
|
|
15
17
|
export interface GraphqlOperationStore {
|
|
16
18
|
readonly get: (toolId: ToolId) => Effect.Effect<{
|
|
17
19
|
binding: OperationBinding;
|
|
18
|
-
|
|
20
|
+
namespace: string;
|
|
19
21
|
} | null>;
|
|
20
|
-
readonly put: (toolId: ToolId, namespace: string, binding: OperationBinding
|
|
22
|
+
readonly put: (toolId: ToolId, namespace: string, binding: OperationBinding) => Effect.Effect<void>;
|
|
21
23
|
readonly remove: (toolId: ToolId) => Effect.Effect<void>;
|
|
22
24
|
readonly listByNamespace: (namespace: string) => Effect.Effect<readonly ToolId[]>;
|
|
23
25
|
readonly removeByNamespace: (namespace: string) => Effect.Effect<readonly ToolId[]>;
|
package/dist/sdk/plugin.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type HeaderValue = HeaderValueValue;
|
|
|
8
8
|
export interface GraphqlSourceConfig {
|
|
9
9
|
/** The GraphQL endpoint URL */
|
|
10
10
|
readonly endpoint: string;
|
|
11
|
+
/** Display name for the source. Falls back to namespace if not provided. */
|
|
12
|
+
readonly name?: string;
|
|
11
13
|
/** Optional: introspection JSON text (if endpoint doesn't support introspection) */
|
|
12
14
|
readonly introspectionJson?: string;
|
|
13
15
|
/** Namespace for the tools (derived from endpoint if not provided) */
|
|
@@ -16,6 +18,7 @@ export interface GraphqlSourceConfig {
|
|
|
16
18
|
readonly headers?: Record<string, HeaderValue>;
|
|
17
19
|
}
|
|
18
20
|
export interface GraphqlUpdateSourceInput {
|
|
21
|
+
readonly name?: string;
|
|
19
22
|
readonly endpoint?: string;
|
|
20
23
|
readonly headers?: Record<string, HeaderValue>;
|
|
21
24
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import { InvocationConfig } from "./types";
|
|
2
3
|
declare const StoredSourceSchema_base: Schema.Class<StoredSourceSchema, {
|
|
3
4
|
namespace: typeof Schema.String;
|
|
4
5
|
name: typeof Schema.String;
|
|
@@ -11,6 +12,7 @@ declare const StoredSourceSchema_base: Schema.Class<StoredSourceSchema, {
|
|
|
11
12
|
prefix: Schema.optional<typeof Schema.String>;
|
|
12
13
|
}>]>>>;
|
|
13
14
|
}>;
|
|
15
|
+
invocationConfig: Schema.optional<typeof InvocationConfig>;
|
|
14
16
|
}, Schema.Struct.Encoded<{
|
|
15
17
|
namespace: typeof Schema.String;
|
|
16
18
|
name: typeof Schema.String;
|
|
@@ -23,10 +25,13 @@ declare const StoredSourceSchema_base: Schema.Class<StoredSourceSchema, {
|
|
|
23
25
|
prefix: Schema.optional<typeof Schema.String>;
|
|
24
26
|
}>]>>>;
|
|
25
27
|
}>;
|
|
28
|
+
invocationConfig: Schema.optional<typeof InvocationConfig>;
|
|
26
29
|
}>, never, {
|
|
27
30
|
readonly name: string;
|
|
28
31
|
} & {
|
|
29
32
|
readonly namespace: string;
|
|
33
|
+
} & {
|
|
34
|
+
readonly invocationConfig?: InvocationConfig | undefined;
|
|
30
35
|
} & {
|
|
31
36
|
readonly config: {
|
|
32
37
|
readonly endpoint: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@executor-js/plugin-graphql",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"homepage": "https://github.com/RhysSullivan/executor/tree/main/packages/plugins/graphql",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/RhysSullivan/executor/issues"
|
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@effect/platform": "^0.96.0",
|
|
44
44
|
"@effect/platform-node": "^0.106.0",
|
|
45
|
-
"@executor/config": "1.4.3
|
|
46
|
-
"@executor-js/sdk": "0.0.1
|
|
45
|
+
"@executor/config": "1.4.3",
|
|
46
|
+
"@executor-js/sdk": "0.0.1",
|
|
47
47
|
"effect": "^3.21.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@effect-atom/atom-react": "^0.5.0",
|
|
51
51
|
"@effect/vitest": "^0.29.0",
|
|
52
|
-
"@executor/api": "1.4.3
|
|
53
|
-
"@executor/react": "1.4.3
|
|
52
|
+
"@executor/api": "1.4.3",
|
|
53
|
+
"@executor/react": "1.4.3",
|
|
54
54
|
"@types/node": "^24.3.1",
|
|
55
55
|
"@types/react": "^19.1.0",
|
|
56
56
|
"bun-types": "^1.2.22",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@effect-atom/atom-react": "^0.5.0",
|
|
63
|
-
"@executor/api": "1.4.3
|
|
64
|
-
"@executor/react": "1.4.3
|
|
63
|
+
"@executor/api": "1.4.3",
|
|
64
|
+
"@executor/react": "1.4.3",
|
|
65
65
|
"@tanstack/react-router": "^1.168.10",
|
|
66
66
|
"react": "^19.1.0"
|
|
67
67
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdk/errors.ts","../src/sdk/introspect.ts","../src/sdk/types.ts","../src/sdk/extract.ts","../src/sdk/invoke.ts","../src/sdk/kv-operation-store.ts","../src/sdk/stored-source.ts","../src/sdk/plugin.ts"],"sourcesContent":["import { Data, Schema } from \"effect\";\nimport type { Option } from \"effect\";\n\nexport class GraphqlIntrospectionError extends Schema.TaggedError<GraphqlIntrospectionError>()(\n \"GraphqlIntrospectionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlExtractionError extends Schema.TaggedError<GraphqlExtractionError>()(\n \"GraphqlExtractionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlInvocationError extends Data.TaggedError(\"GraphqlInvocationError\")<{\n readonly message: string;\n readonly statusCode: Option.Option<number>;\n readonly cause?: unknown;\n}> {}\n","import { Effect } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"@effect/platform\";\n\nimport { GraphqlIntrospectionError } from \"./errors\";\n\n// ---------------------------------------------------------------------------\n// Introspection query — standard GraphQL introspection\n// ---------------------------------------------------------------------------\n\nconst INTROSPECTION_QUERY = `\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n types {\n kind\n name\n description\n fields(includeDeprecated: false) {\n name\n description\n args {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n type {\n ...TypeRef\n }\n }\n inputFields {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n enumValues(includeDeprecated: false) {\n name\n description\n }\n }\n }\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Introspection result types\n// ---------------------------------------------------------------------------\n\nexport interface IntrospectionTypeRef {\n readonly kind: string;\n readonly name: string | null;\n readonly ofType: IntrospectionTypeRef | null;\n}\n\nexport interface IntrospectionInputValue {\n readonly name: string;\n readonly description: string | null;\n readonly type: IntrospectionTypeRef;\n readonly defaultValue: string | null;\n}\n\nexport interface IntrospectionField {\n readonly name: string;\n readonly description: string | null;\n readonly args: readonly IntrospectionInputValue[];\n readonly type: IntrospectionTypeRef;\n}\n\nexport interface IntrospectionEnumValue {\n readonly name: string;\n readonly description: string | null;\n}\n\nexport interface IntrospectionType {\n readonly kind: string;\n readonly name: string;\n readonly description: string | null;\n readonly fields: readonly IntrospectionField[] | null;\n readonly inputFields: readonly IntrospectionInputValue[] | null;\n readonly enumValues: readonly IntrospectionEnumValue[] | null;\n}\n\nexport interface IntrospectionSchema {\n readonly queryType: { readonly name: string } | null;\n readonly mutationType: { readonly name: string } | null;\n readonly types: readonly IntrospectionType[];\n}\n\nexport interface IntrospectionResult {\n readonly __schema: IntrospectionSchema;\n}\n\n// ---------------------------------------------------------------------------\n// Introspect a GraphQL endpoint\n// ---------------------------------------------------------------------------\n\nexport const introspect = Effect.fn(\"GraphQL.introspect\")(function* (\n endpoint: string,\n headers?: Record<string, string>,\n) {\n const client = yield* HttpClient.HttpClient;\n\n let request = HttpClientRequest.post(endpoint).pipe(\n HttpClientRequest.setHeader(\"Content-Type\", \"application/json\"),\n HttpClientRequest.bodyUnsafeJson({\n query: INTROSPECTION_QUERY,\n }),\n );\n\n if (headers) {\n for (const [k, v] of Object.entries(headers)) {\n request = HttpClientRequest.setHeader(request, k, v);\n }\n }\n\n const response = yield* client.execute(request).pipe(\n Effect.tapErrorCause((cause) => Effect.logError(\"graphql introspection request failed\", cause)),\n Effect.mapError(\n (err) =>\n new GraphqlIntrospectionError({\n message: `Failed to reach GraphQL endpoint: ${err.message}`,\n }),\n ),\n );\n\n if (response.status !== 200) {\n return yield* new GraphqlIntrospectionError({\n message: `Introspection failed with status ${response.status}`,\n });\n }\n\n const raw = yield* response.json.pipe(\n Effect.tapErrorCause((cause) =>\n Effect.logError(\"graphql introspection JSON parse failed\", cause),\n ),\n Effect.mapError(\n () =>\n new GraphqlIntrospectionError({\n message: `Failed to parse introspection response as JSON`,\n }),\n ),\n );\n\n const json = raw as { data?: IntrospectionResult; errors?: unknown[] };\n\n if (json.errors && Array.isArray(json.errors) && json.errors.length > 0) {\n return yield* new GraphqlIntrospectionError({\n message: `Introspection returned ${json.errors.length} error(s)`,\n });\n }\n\n if (!json.data?.__schema) {\n return yield* new GraphqlIntrospectionError({\n message: \"Introspection response missing __schema\",\n });\n }\n\n return json.data;\n});\n\n// ---------------------------------------------------------------------------\n// Parse an introspection result from a JSON string (for offline/text input)\n// ---------------------------------------------------------------------------\n\nexport const parseIntrospectionJson = (\n text: string,\n): Effect.Effect<IntrospectionResult, GraphqlIntrospectionError> =>\n Effect.try({\n try: () => {\n const parsed = JSON.parse(text);\n // Accept both { data: { __schema } } and { __schema } formats\n const result = parsed.data ?? parsed;\n if (!result.__schema) {\n throw new Error(\"Missing __schema in introspection JSON\");\n }\n return result as IntrospectionResult;\n },\n catch: (err) =>\n new GraphqlIntrospectionError({\n message: `Failed to parse introspection JSON: ${err instanceof Error ? err.message : String(err)}`,\n }),\n });\n","import { Schema } from \"effect\";\n\n// ---------------------------------------------------------------------------\n// GraphQL operation kind\n// ---------------------------------------------------------------------------\n\nexport const GraphqlOperationKind = Schema.Literal(\"query\", \"mutation\");\nexport type GraphqlOperationKind = typeof GraphqlOperationKind.Type;\n\n// ---------------------------------------------------------------------------\n// Extracted field (becomes a tool)\n// ---------------------------------------------------------------------------\n\nexport class GraphqlArgument extends Schema.Class<GraphqlArgument>(\"GraphqlArgument\")({\n name: Schema.String,\n typeName: Schema.String,\n required: Schema.Boolean,\n description: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n}) {}\n\nexport class ExtractedField extends Schema.Class<ExtractedField>(\"ExtractedField\")({\n /** e.g. \"user\", \"createUser\" */\n fieldName: Schema.String,\n /** \"query\" or \"mutation\" */\n kind: GraphqlOperationKind,\n description: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n arguments: Schema.Array(GraphqlArgument),\n /** JSON Schema for the input (built from arguments) */\n inputSchema: Schema.optionalWith(Schema.Unknown, { as: \"Option\" }),\n /** The return type name for documentation */\n returnTypeName: Schema.String,\n}) {}\n\nexport class ExtractionResult extends Schema.Class<ExtractionResult>(\"ExtractionResult\")({\n /** Schema name from introspection */\n schemaName: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n fields: Schema.Array(ExtractedField),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Operation binding — minimal data needed to invoke\n// ---------------------------------------------------------------------------\n\nexport class OperationBinding extends Schema.Class<OperationBinding>(\"OperationBinding\")({\n kind: GraphqlOperationKind,\n fieldName: Schema.String,\n /** The full GraphQL query/mutation string */\n operationString: Schema.String,\n /** Ordered variable names for mapping */\n variableNames: Schema.Array(Schema.String),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Invocation\n// ---------------------------------------------------------------------------\n\nexport const HeaderValue = Schema.Union(\n Schema.String,\n Schema.Struct({\n secretId: Schema.String,\n prefix: Schema.optional(Schema.String),\n }),\n);\nexport type HeaderValue = typeof HeaderValue.Type;\n\nexport class InvocationConfig extends Schema.Class<InvocationConfig>(\"InvocationConfig\")({\n /** The GraphQL endpoint URL */\n endpoint: Schema.String,\n /** Headers applied to every request. Values can reference secrets. */\n headers: Schema.optionalWith(Schema.Record({ key: Schema.String, value: HeaderValue }), {\n default: () => ({}),\n }),\n}) {}\n\nexport class InvocationResult extends Schema.Class<InvocationResult>(\"InvocationResult\")({\n status: Schema.Number,\n data: Schema.NullOr(Schema.Unknown),\n errors: Schema.NullOr(Schema.Unknown),\n}) {}\n","import { Effect, Option } from \"effect\";\n\nimport { GraphqlExtractionError } from \"./errors\";\nimport type {\n IntrospectionResult,\n IntrospectionSchema,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionInputValue,\n} from \"./introspect\";\nimport {\n ExtractedField,\n ExtractionResult,\n GraphqlArgument,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Type ref helpers\n// ---------------------------------------------------------------------------\n\n/** Unwrap NON_NULL / LIST wrappers to get the leaf type name */\nconst unwrapTypeName = (ref: IntrospectionTypeRef): string => {\n if (ref.name) return ref.name;\n if (ref.ofType) return unwrapTypeName(ref.ofType);\n return \"Unknown\";\n};\n\n/** Check if a type ref is non-null (required) */\nconst isNonNull = (ref: IntrospectionTypeRef): boolean => ref.kind === \"NON_NULL\";\n\n// ---------------------------------------------------------------------------\n// Build shared definitions from all INPUT_OBJECT and ENUM types\n// ---------------------------------------------------------------------------\n\nconst buildDefinitions = (\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> => {\n const defs: Record<string, unknown> = {};\n\n for (const [name, type] of types) {\n // Skip internal types\n if (name.startsWith(\"__\")) continue;\n\n if (type.kind === \"INPUT_OBJECT\" && type.inputFields) {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const field of type.inputFields) {\n const schema = typeRefToJsonSchema(field.type, types);\n if (field.description) {\n (schema as Record<string, unknown>).description = field.description;\n }\n properties[field.name] = schema;\n if (isNonNull(field.type)) {\n required.push(field.name);\n }\n }\n\n const def: Record<string, unknown> = { type: \"object\", properties };\n if (required.length > 0) def.required = required;\n if (type.description) def.description = type.description;\n defs[name] = def;\n }\n\n if (type.kind === \"ENUM\" && type.enumValues) {\n defs[name] = {\n type: \"string\",\n enum: type.enumValues.map((v) => v.name),\n ...(type.description ? { description: type.description } : {}),\n };\n }\n }\n\n return defs;\n};\n\n// ---------------------------------------------------------------------------\n// Convert a type ref to JSON Schema using $ref for complex types\n// ---------------------------------------------------------------------------\n\nconst typeRefToJsonSchema = (\n ref: IntrospectionTypeRef,\n // oxlint-disable-next-line only-used-in-recursion\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? typeRefToJsonSchema(ref.ofType, types) : {};\n\n case \"LIST\":\n return {\n type: \"array\",\n items: ref.ofType ? typeRefToJsonSchema(ref.ofType, types) : {},\n };\n\n case \"SCALAR\":\n return scalarToJsonSchema(ref.name ?? \"String\");\n\n case \"ENUM\":\n // Reference the shared definition\n return ref.name ? { $ref: `#/$defs/${ref.name}` } : { type: \"string\" };\n\n case \"INPUT_OBJECT\":\n // Reference the shared definition — no recursive expansion needed\n return ref.name ? { $ref: `#/$defs/${ref.name}` } : { type: \"object\" };\n\n case \"OBJECT\":\n case \"INTERFACE\":\n case \"UNION\":\n return { type: \"object\" };\n\n default:\n return {};\n }\n};\n\nconst scalarToJsonSchema = (name: string): Record<string, unknown> => {\n switch (name) {\n case \"String\":\n case \"ID\":\n return { type: \"string\" };\n case \"Int\":\n return { type: \"integer\" };\n case \"Float\":\n return { type: \"number\" };\n case \"Boolean\":\n return { type: \"boolean\" };\n default:\n return { type: \"string\", description: `Custom scalar: ${name}` };\n }\n};\n\n// ---------------------------------------------------------------------------\n// Build input JSON Schema from field arguments\n// ---------------------------------------------------------------------------\n\nconst buildInputSchema = (\n args: readonly IntrospectionInputValue[],\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> | undefined => {\n if (args.length === 0) return undefined;\n\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const arg of args) {\n const schema = typeRefToJsonSchema(arg.type, types);\n if (arg.description) {\n (schema as Record<string, unknown>).description = arg.description;\n }\n properties[arg.name] = schema;\n if (isNonNull(arg.type)) {\n required.push(arg.name);\n }\n }\n\n const inputSchema: Record<string, unknown> = {\n type: \"object\",\n properties,\n };\n if (required.length > 0) inputSchema.required = required;\n return inputSchema;\n};\n\n/** Format a type ref back to GraphQL type notation (e.g. \"[String!]!\") */\nconst formatTypeRef = (ref: IntrospectionTypeRef): string => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? `${formatTypeRef(ref.ofType)}!` : \"Unknown!\";\n case \"LIST\":\n return ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : \"[Unknown]\";\n default:\n return ref.name ?? \"Unknown\";\n }\n};\n\n// ---------------------------------------------------------------------------\n// Extract fields from schema\n// ---------------------------------------------------------------------------\n\nconst extractFields = (\n _schema: IntrospectionSchema,\n kind: GraphqlOperationKind,\n typeName: string | null | undefined,\n types: ReadonlyMap<string, IntrospectionType>,\n): ExtractedField[] => {\n if (!typeName) return [];\n\n const type = types.get(typeName);\n if (!type?.fields) return [];\n\n return type.fields\n .filter((f) => !f.name.startsWith(\"__\"))\n .map((field) => {\n const args = field.args.map(\n (arg) =>\n new GraphqlArgument({\n name: arg.name,\n typeName: formatTypeRef(arg.type),\n required: isNonNull(arg.type),\n description: arg.description ? Option.some(arg.description) : Option.none(),\n }),\n );\n\n const inputSchema = buildInputSchema(field.args, types);\n\n return new ExtractedField({\n fieldName: field.name,\n kind,\n description: field.description ? Option.some(field.description) : Option.none(),\n arguments: args,\n inputSchema: inputSchema ? Option.some(inputSchema) : Option.none(),\n returnTypeName: unwrapTypeName(field.type),\n });\n });\n};\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\nexport interface ExtractionOutput {\n readonly result: ExtractionResult;\n /** Shared JSON Schema definitions for INPUT_OBJECT and ENUM types.\n * Tool input schemas use `$ref` pointers into these. */\n readonly definitions: Record<string, unknown>;\n}\n\nexport const extract = (\n introspection: IntrospectionResult,\n): Effect.Effect<ExtractionOutput, GraphqlExtractionError> =>\n Effect.try({\n try: () => {\n const schema = introspection.__schema;\n const typeMap = new Map<string, IntrospectionType>();\n for (const t of schema.types) {\n typeMap.set(t.name, t);\n }\n\n const definitions = buildDefinitions(typeMap);\n\n const queryFields = extractFields(schema, \"query\", schema.queryType?.name, typeMap);\n const mutationFields = extractFields(schema, \"mutation\", schema.mutationType?.name, typeMap);\n\n return {\n result: new ExtractionResult({\n schemaName: Option.none(),\n fields: [...queryFields, ...mutationFields],\n }),\n definitions,\n };\n },\n catch: (err) =>\n new GraphqlExtractionError({\n message: `Failed to extract GraphQL schema: ${err instanceof Error ? err.message : String(err)}`,\n }),\n });\n","import { Effect, Layer, Option } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"@effect/platform\";\n\nimport {\n type ToolId,\n type ToolInvoker,\n ToolInvocationResult,\n ToolInvocationError,\n type ScopeId,\n type SecretId,\n} from \"@executor/sdk\";\n\nimport { GraphqlInvocationError } from \"./errors\";\nimport type { GraphqlOperationStore } from \"./operation-store\";\nimport {\n type HeaderValue,\n type OperationBinding,\n InvocationConfig,\n InvocationResult,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Header resolution — resolves secret refs at invocation time\n// ---------------------------------------------------------------------------\n\nconst resolveHeaders = (\n headers: Record<string, HeaderValue>,\n secrets: {\n readonly resolve: (secretId: SecretId, scopeId: ScopeId) => Effect.Effect<string, unknown>;\n },\n scopeId: ScopeId,\n): Effect.Effect<Record<string, string>, ToolInvocationError> =>\n Effect.gen(function* () {\n const resolved: Record<string, string> = {};\n for (const [name, value] of Object.entries(headers)) {\n if (typeof value === \"string\") {\n resolved[name] = value;\n } else {\n const secret = yield* secrets.resolve(value.secretId as SecretId, scopeId).pipe(\n Effect.mapError(\n () =>\n new ToolInvocationError({\n toolId: \"\" as ToolId,\n message: `Failed to resolve secret \"${value.secretId}\" for header \"${name}\"`,\n cause: undefined,\n }),\n ),\n );\n resolved[name] = value.prefix ? `${value.prefix}${secret}` : secret;\n }\n }\n return resolved;\n });\n\n// ---------------------------------------------------------------------------\n// Response helpers\n// ---------------------------------------------------------------------------\n\nconst isJsonContentType = (ct: string | null | undefined): boolean => {\n if (!ct) return false;\n const normalized = ct.split(\";\")[0]?.trim().toLowerCase() ?? \"\";\n return (\n normalized === \"application/json\" || normalized.includes(\"+json\") || normalized.includes(\"json\")\n );\n};\n\n// ---------------------------------------------------------------------------\n// Public API — execute a GraphQL operation\n// ---------------------------------------------------------------------------\n\nexport const invoke = Effect.fn(\"GraphQL.invoke\")(function* (\n operation: OperationBinding,\n args: Record<string, unknown>,\n config: InvocationConfig,\n resolvedHeaders?: Record<string, string>,\n) {\n const client = yield* HttpClient.HttpClient;\n\n // Build the GraphQL request body\n const variables: Record<string, unknown> = {};\n for (const varName of operation.variableNames) {\n if (args[varName] !== undefined) {\n variables[varName] = args[varName];\n }\n }\n\n // Also pick up any variables from a \"variables\" container\n if (typeof args.variables === \"object\" && args.variables !== null) {\n Object.assign(variables, args.variables);\n }\n\n let request = HttpClientRequest.post(config.endpoint).pipe(\n HttpClientRequest.setHeader(\"Content-Type\", \"application/json\"),\n HttpClientRequest.bodyUnsafeJson({\n query: operation.operationString,\n variables: Object.keys(variables).length > 0 ? variables : undefined,\n }),\n );\n\n // Apply resolved headers\n if (resolvedHeaders) {\n for (const [name, value] of Object.entries(resolvedHeaders)) {\n request = HttpClientRequest.setHeader(request, name, value);\n }\n }\n\n const response = yield* client.execute(request).pipe(\n Effect.mapError(\n (err) =>\n new GraphqlInvocationError({\n message: `GraphQL request failed: ${err.message}`,\n statusCode: Option.none(),\n cause: err,\n }),\n ),\n );\n\n const status = response.status;\n const contentType = response.headers[\"content-type\"] ?? null;\n\n const body: unknown = isJsonContentType(contentType)\n ? yield* response.json.pipe(Effect.catchAll(() => response.text))\n : yield* response.text;\n\n // GraphQL responses are always 200 with { data, errors }\n const gqlBody = body as { data?: unknown; errors?: unknown[] } | null;\n const hasErrors = Array.isArray(gqlBody?.errors) && gqlBody.errors.length > 0;\n\n return new InvocationResult({\n status,\n data: gqlBody?.data ?? null,\n errors: hasErrors ? gqlBody!.errors : null,\n });\n});\n\n// ---------------------------------------------------------------------------\n// ToolInvoker — bridges operation store + HTTP client into SDK invoker\n// ---------------------------------------------------------------------------\n\nexport const makeGraphqlInvoker = (opts: {\n readonly operationStore: GraphqlOperationStore;\n readonly httpClientLayer: Layer.Layer<HttpClient.HttpClient>;\n readonly secrets: {\n readonly resolve: (secretId: SecretId, scopeId: ScopeId) => Effect.Effect<string, unknown>;\n };\n readonly scopeId: ScopeId;\n}): ToolInvoker => ({\n resolveAnnotations: (toolId: ToolId) =>\n Effect.gen(function* () {\n const entry = yield* opts.operationStore.get(toolId);\n if (!entry) return undefined;\n // Mutations require approval, queries don't\n if (entry.binding.kind === \"mutation\") {\n return {\n requiresApproval: true,\n approvalDescription: `mutation ${entry.binding.fieldName}`,\n };\n }\n return {};\n }),\n\n invoke: (toolId: ToolId, args: unknown) =>\n Effect.gen(function* () {\n const entry = yield* opts.operationStore.get(toolId);\n if (!entry) {\n return yield* new ToolInvocationError({\n toolId,\n message: `No GraphQL operation found for tool \"${toolId}\"`,\n cause: undefined,\n });\n }\n\n const { binding, config } = entry;\n\n // Resolve secret-backed headers\n const resolvedHeaders = yield* resolveHeaders(config.headers, opts.secrets, opts.scopeId);\n\n const result = yield* invoke(\n binding,\n (args ?? {}) as Record<string, unknown>,\n config,\n resolvedHeaders,\n ).pipe(Effect.provide(opts.httpClientLayer));\n\n return new ToolInvocationResult({\n data: result.data,\n error: result.errors,\n status: result.status,\n });\n }).pipe(\n Effect.catchAll((err) => {\n if (\n typeof err === \"object\" &&\n err !== null &&\n \"_tag\" in err &&\n (err as { _tag: string })._tag === \"ToolInvocationError\"\n ) {\n return Effect.fail(err as ToolInvocationError);\n }\n return Effect.fail(\n new ToolInvocationError({\n toolId,\n message: `GraphQL invocation failed: ${err instanceof Error ? err.message : String(err)}`,\n cause: err,\n }),\n );\n }),\n ),\n});\n","// ---------------------------------------------------------------------------\n// KV-backed GraphqlOperationStore\n// ---------------------------------------------------------------------------\n\nimport { Effect, Schema } from \"effect\";\nimport { scopeKv, makeInMemoryScopedKv, type Kv, type ToolId, type ScopedKv } from \"@executor/sdk\";\n\nimport type { GraphqlOperationStore, StoredSource } from \"./operation-store\";\nimport { OperationBinding, InvocationConfig } from \"./types\";\nimport { StoredSourceSchema } from \"./stored-source\";\n\n// ---------------------------------------------------------------------------\n// Stored schemas\n// ---------------------------------------------------------------------------\n\nclass StoredEntry extends Schema.Class<StoredEntry>(\"StoredEntry\")({\n namespace: Schema.String,\n binding: OperationBinding,\n config: InvocationConfig,\n}) {}\n\nconst encodeEntry = Schema.encodeSync(Schema.parseJson(StoredEntry));\nconst decodeEntry = Schema.decodeUnknownSync(Schema.parseJson(StoredEntry));\n\nconst encodeSource = Schema.encodeSync(Schema.parseJson(StoredSourceSchema));\nconst decodeSource = Schema.decodeUnknownSync(Schema.parseJson(StoredSourceSchema));\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\nconst makeStore = (bindings: ScopedKv, sources: ScopedKv): GraphqlOperationStore => ({\n get: (toolId) =>\n Effect.gen(function* () {\n const raw = yield* bindings.get(toolId);\n if (!raw) return null;\n const entry = decodeEntry(raw);\n return { binding: entry.binding, config: entry.config };\n }),\n\n put: (toolId, namespace, binding, config) =>\n bindings.set([\n { key: toolId, value: encodeEntry(new StoredEntry({ namespace, binding, config })) },\n ]),\n\n remove: (toolId) => bindings.delete([toolId]).pipe(Effect.asVoid),\n\n listByNamespace: (namespace) =>\n Effect.gen(function* () {\n const entries = yield* bindings.list();\n const ids: ToolId[] = [];\n for (const e of entries) {\n const entry = decodeEntry(e.value);\n if (entry.namespace === namespace) ids.push(e.key as ToolId);\n }\n return ids;\n }),\n\n removeByNamespace: (namespace) =>\n Effect.gen(function* () {\n const entries = yield* bindings.list();\n const ids: ToolId[] = [];\n for (const e of entries) {\n const entry = decodeEntry(e.value);\n if (entry.namespace === namespace) ids.push(e.key as ToolId);\n }\n if (ids.length > 0) yield* bindings.delete(ids);\n return ids;\n }),\n\n putSource: (source) => sources.set([{ key: source.namespace, value: encodeSource(source) }]),\n\n removeSource: (namespace) => sources.delete([namespace]).pipe(Effect.asVoid),\n\n listSources: () =>\n Effect.gen(function* () {\n const entries = yield* sources.list();\n return entries.map((e) => decodeSource(e.value) as StoredSource);\n }),\n\n getSource: (namespace) =>\n Effect.gen(function* () {\n const raw = yield* sources.get(namespace);\n if (!raw) return null;\n return decodeSource(raw) as StoredSource;\n }),\n\n getSourceConfig: (namespace) =>\n Effect.gen(function* () {\n const raw = yield* sources.get(namespace);\n if (!raw) return null;\n const source = decodeSource(raw) as StoredSource;\n return source.config;\n }),\n});\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nexport const makeKvOperationStore = (kv: Kv, namespace: string): GraphqlOperationStore =>\n makeStore(scopeKv(kv, `${namespace}.bindings`), scopeKv(kv, `${namespace}.sources`));\n\nexport const makeInMemoryOperationStore = (): GraphqlOperationStore =>\n makeStore(makeInMemoryScopedKv(), makeInMemoryScopedKv());\n","import { Schema } from \"effect\";\n\nimport { HeaderValue } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Stored source — the shape persisted by the operation store and exposed\n// via the getSource HTTP endpoint.\n// ---------------------------------------------------------------------------\n\nexport class StoredSourceSchema extends Schema.Class<StoredSourceSchema>(\"GraphqlStoredSource\")({\n namespace: Schema.String,\n name: Schema.String,\n config: Schema.Struct({\n endpoint: Schema.String,\n introspectionJson: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record({ key: Schema.String, value: HeaderValue })),\n }),\n}) {}\n\nexport type StoredSourceSchemaType = typeof StoredSourceSchema.Type;\n","import { Effect, Option, Schema } from \"effect\";\nimport { FetchHttpClient, HttpClient } from \"@effect/platform\";\nimport type { Layer } from \"effect\";\n\nimport {\n Source,\n SourceDetectionResult,\n definePlugin,\n registerRuntimeTools,\n runtimeTool,\n type ExecutorPlugin,\n type PluginContext,\n ToolId,\n type SecretId,\n type ToolRegistration,\n} from \"@executor/sdk\";\n\nimport {\n introspect,\n parseIntrospectionJson,\n type IntrospectionResult,\n type IntrospectionType,\n type IntrospectionField,\n} from \"./introspect\";\nimport { extract } from \"./extract\";\nimport { GraphqlExtractionError } from \"./errors\";\nimport { makeGraphqlInvoker } from \"./invoke\";\nimport type { GraphqlOperationStore, StoredSource } from \"./operation-store\";\nimport { makeInMemoryOperationStore } from \"./kv-operation-store\";\nimport {\n ExtractedField,\n HeaderValue as HeaderValueSchema,\n InvocationConfig,\n OperationBinding,\n type HeaderValue as HeaderValueValue,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Plugin config\n// ---------------------------------------------------------------------------\n\nexport type HeaderValue = HeaderValueValue;\n\nexport interface GraphqlSourceConfig {\n /** The GraphQL endpoint URL */\n readonly endpoint: string;\n /** Optional: introspection JSON text (if endpoint doesn't support introspection) */\n readonly introspectionJson?: string;\n /** Namespace for the tools (derived from endpoint if not provided) */\n readonly namespace?: string;\n /** Headers applied to every request. Values can reference secrets. */\n readonly headers?: Record<string, HeaderValue>;\n}\n\n// ---------------------------------------------------------------------------\n// Plugin extension\n// ---------------------------------------------------------------------------\n\nexport interface GraphqlUpdateSourceInput {\n readonly endpoint?: string;\n readonly headers?: Record<string, HeaderValue>;\n}\n\nexport interface GraphqlPluginExtension {\n /** Add a GraphQL endpoint and register its operations as tools */\n readonly addSource: (\n config: GraphqlSourceConfig,\n ) => Effect.Effect<{ readonly toolCount: number }, Error>;\n\n /** Remove all tools from a previously added GraphQL source by namespace */\n readonly removeSource: (namespace: string) => Effect.Effect<void>;\n\n /** Fetch the full stored source by namespace (or null if missing) */\n readonly getSource: (namespace: string) => Effect.Effect<StoredSource | null>;\n\n /** Update config (endpoint, headers) for an existing GraphQL source */\n readonly updateSource: (\n namespace: string,\n input: GraphqlUpdateSourceInput,\n ) => Effect.Effect<void>;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst AddSourceInputSchema = Schema.Struct({\n endpoint: Schema.String,\n introspectionJson: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record({ key: Schema.String, value: HeaderValueSchema })),\n});\ntype AddSourceInput = typeof AddSourceInputSchema.Type;\n\nconst AddSourceOutputSchema = Schema.Struct({\n sourceId: Schema.String,\n toolCount: Schema.Number,\n});\n\n/** Derive a namespace from an endpoint URL */\nconst namespaceFromEndpoint = (endpoint: string): string => {\n try {\n const url = new URL(endpoint);\n return url.hostname.replace(/[^a-z0-9]+/gi, \"_\").toLowerCase();\n } catch {\n return \"graphql\";\n }\n};\n\nconst buildOperationStringForField = (\n kind: GraphqlOperationKind,\n field: IntrospectionField,\n types: ReadonlyMap<string, IntrospectionType>,\n): string => {\n const opType = kind === \"query\" ? \"query\" : \"mutation\";\n\n const varDefs = field.args.map((arg) => {\n const typeName = formatTypeRef(arg.type);\n return `$${arg.name}: ${typeName}`;\n });\n\n const argPasses = field.args.map((arg) => `${arg.name}: $${arg.name}`);\n const selectionSet = buildSelectionSet(field.type, types, 0, new Set());\n\n const varDefsStr = varDefs.length > 0 ? `(${varDefs.join(\", \")})` : \"\";\n const argPassStr = argPasses.length > 0 ? `(${argPasses.join(\", \")})` : \"\";\n\n return `${opType}${varDefsStr} { ${field.name}${argPassStr}${selectionSet ? ` ${selectionSet}` : \"\"} }`;\n};\n\nimport type { IntrospectionTypeRef } from \"./introspect\";\n\nconst formatTypeRef = (ref: IntrospectionTypeRef): string => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? `${formatTypeRef(ref.ofType)}!` : \"Unknown!\";\n case \"LIST\":\n return ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : \"[Unknown]\";\n default:\n return ref.name ?? \"Unknown\";\n }\n};\n\nconst unwrapTypeName = (ref: IntrospectionTypeRef): string => {\n if (ref.name) return ref.name;\n if (ref.ofType) return unwrapTypeName(ref.ofType);\n return \"Unknown\";\n};\n\nconst buildSelectionSet = (\n ref: IntrospectionTypeRef,\n types: ReadonlyMap<string, IntrospectionType>,\n depth: number,\n seen: Set<string>,\n): string => {\n if (depth > 2) return \"\";\n\n const leafName = unwrapTypeName(ref);\n if (seen.has(leafName)) return \"\";\n\n const objectType = types.get(leafName);\n if (!objectType?.fields) return \"\";\n\n const kind = objectType.kind;\n if (kind === \"SCALAR\" || kind === \"ENUM\") return \"\";\n\n seen.add(leafName);\n\n const subFields = objectType.fields\n .filter((f) => !f.name.startsWith(\"__\"))\n .slice(0, 12)\n .map((f) => {\n const sub = buildSelectionSet(f.type, types, depth + 1, seen);\n return sub ? `${f.name} ${sub}` : f.name;\n });\n\n seen.delete(leafName);\n\n return subFields.length > 0 ? `{ ${subFields.join(\" \")} }` : \"\";\n};\n\nconst toRegistration = (field: ExtractedField, namespace: string): ToolRegistration => {\n const prefix = field.kind === \"mutation\" ? \"mutation\" : \"query\";\n const toolPath = `${prefix}.${field.fieldName}`;\n const description = Option.getOrElse(\n field.description,\n () => `GraphQL ${field.kind}: ${field.fieldName} -> ${field.returnTypeName}`,\n );\n\n return {\n id: ToolId.make(`${namespace}.${toolPath}`),\n pluginKey: \"graphql\",\n sourceId: namespace,\n name: toolPath,\n description,\n inputSchema: Option.getOrUndefined(field.inputSchema),\n outputSchema: undefined,\n };\n};\n\n// ---------------------------------------------------------------------------\n// Plugin factory\n// ---------------------------------------------------------------------------\n\nexport const graphqlPlugin = (options?: {\n readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient>;\n readonly operationStore?: GraphqlOperationStore;\n}): ExecutorPlugin<\"graphql\", GraphqlPluginExtension> => {\n const httpClientLayer = options?.httpClientLayer ?? FetchHttpClient.layer;\n const operationStore = options?.operationStore ?? makeInMemoryOperationStore();\n\n return definePlugin({\n key: \"graphql\",\n init: (ctx: PluginContext) =>\n Effect.gen(function* () {\n yield* ctx.tools.registerInvoker(\n \"graphql\",\n makeGraphqlInvoker({\n operationStore,\n httpClientLayer,\n secrets: ctx.secrets,\n scopeId: ctx.scope.id,\n }),\n );\n\n yield* ctx.sources.addManager({\n kind: \"graphql\",\n\n list: () =>\n operationStore.listSources().pipe(\n Effect.map((metas) =>\n metas.map(\n (s) =>\n new Source({\n id: s.namespace,\n name: s.name,\n kind: \"graphql\",\n runtime: false,\n canRemove: true,\n canRefresh: false,\n canEdit: true,\n }),\n ),\n ),\n ),\n\n remove: (sourceId: string) =>\n Effect.gen(function* () {\n yield* operationStore.removeByNamespace(sourceId);\n yield* operationStore.removeSource(sourceId);\n yield* ctx.tools.unregisterBySource(sourceId);\n }),\n\n detect: (url: string) =>\n Effect.gen(function* () {\n const trimmed = url.trim();\n if (!trimmed) return null;\n const parsed = yield* Effect.try(() => new URL(trimmed)).pipe(Effect.option);\n if (parsed._tag === \"None\") return null;\n\n const ok = yield* introspect(trimmed).pipe(\n Effect.provide(httpClientLayer),\n Effect.map(() => true),\n Effect.catchAll(() => Effect.succeed(false)),\n );\n\n if (!ok) return null;\n\n const name = namespaceFromEndpoint(trimmed);\n return new SourceDetectionResult({\n kind: \"graphql\",\n confidence: \"high\",\n endpoint: trimmed,\n name,\n namespace: name,\n });\n }),\n });\n\n const addSourceInternal = (config: GraphqlSourceConfig) =>\n Effect.gen(function* () {\n // Get introspection result — either by querying the endpoint or parsing provided JSON\n let introspectionResult: IntrospectionResult;\n if (config.introspectionJson) {\n introspectionResult = yield* parseIntrospectionJson(config.introspectionJson);\n } else {\n // Resolve all headers (including secret refs) for introspection\n const resolvedHeaders: Record<string, string> = {};\n if (config.headers) {\n for (const [name, value] of Object.entries(config.headers)) {\n if (typeof value === \"string\") {\n resolvedHeaders[name] = value;\n } else {\n const secret = yield* ctx.secrets\n .resolve(value.secretId as SecretId, ctx.scope.id)\n .pipe(Effect.catchAll(() => Effect.succeed(\"\")));\n if (secret) {\n resolvedHeaders[name] = value.prefix ? `${value.prefix}${secret}` : secret;\n }\n }\n }\n }\n\n introspectionResult = yield* introspect(\n config.endpoint,\n Object.keys(resolvedHeaders).length > 0 ? resolvedHeaders : undefined,\n ).pipe(Effect.provide(httpClientLayer));\n }\n\n const { result, definitions } = yield* extract(introspectionResult);\n const namespace = config.namespace ?? namespaceFromEndpoint(config.endpoint);\n\n // Register shared JSON Schema definitions ($ref targets)\n if (Object.keys(definitions).length > 0) {\n yield* ctx.tools.registerDefinitions(definitions);\n }\n\n const invocationConfig = new InvocationConfig({\n endpoint: config.endpoint,\n headers: config.headers ?? {},\n });\n\n // Build type map for operation string generation\n const typeMap = new Map<string, IntrospectionType>();\n for (const t of introspectionResult.__schema.types) {\n typeMap.set(t.name, t);\n }\n\n // Build field map for operation strings\n const fieldMap = new Map<\n string,\n { kind: GraphqlOperationKind; field: IntrospectionField }\n >();\n const schema = introspectionResult.__schema;\n\n for (const rootKind of [\"query\", \"mutation\"] as const) {\n const typeName =\n rootKind === \"query\" ? schema.queryType?.name : schema.mutationType?.name;\n if (!typeName) continue;\n const rootType = typeMap.get(typeName);\n if (!rootType?.fields) continue;\n for (const f of rootType.fields) {\n if (!f.name.startsWith(\"__\")) {\n fieldMap.set(`${rootKind}.${f.name}`, { kind: rootKind, field: f });\n }\n }\n }\n\n const registrations: ToolRegistration[] = [];\n\n yield* Effect.forEach(\n result.fields,\n (extractedField) => {\n const reg = toRegistration(extractedField, namespace);\n registrations.push(reg);\n\n const key = `${extractedField.kind}.${extractedField.fieldName}`;\n const entry = fieldMap.get(key);\n\n const operationString = entry\n ? buildOperationStringForField(entry.kind, entry.field, typeMap)\n : `${extractedField.kind} { ${extractedField.fieldName} }`;\n\n const binding = new OperationBinding({\n kind: extractedField.kind,\n fieldName: extractedField.fieldName,\n operationString,\n variableNames: extractedField.arguments.map((a) => a.name),\n });\n\n return operationStore.put(reg.id, namespace, binding, invocationConfig);\n },\n { discard: true },\n );\n\n yield* ctx.tools.register(registrations);\n\n yield* operationStore.putSource({\n namespace,\n name: namespace,\n config: {\n endpoint: config.endpoint,\n introspectionJson: config.introspectionJson,\n namespace: config.namespace,\n headers: config.headers,\n },\n });\n\n return { sourceId: namespace, toolCount: registrations.length };\n });\n\n const runtimeTools = yield* registerRuntimeTools({\n registry: ctx.tools,\n sources: ctx.sources,\n pluginKey: \"graphql\",\n source: {\n id: \"built-in\",\n name: \"Built In\",\n kind: \"built-in\",\n },\n tools: [\n runtimeTool({\n id: \"graphql.addSource\",\n name: \"graphql.addSource\",\n description: \"Add a GraphQL endpoint and register its operations as tools\",\n inputSchema: AddSourceInputSchema,\n outputSchema: AddSourceOutputSchema,\n handler: (input: AddSourceInput) => addSourceInternal(input),\n }),\n ],\n });\n\n return {\n extension: {\n addSource: (config: GraphqlSourceConfig) =>\n addSourceInternal(config).pipe(\n Effect.map(({ toolCount }) => ({ toolCount })),\n Effect.mapError(\n (err) =>\n new GraphqlExtractionError({\n message: err instanceof Error ? err.message : String(err),\n }),\n ),\n ),\n\n removeSource: (namespace: string) =>\n Effect.gen(function* () {\n const toolIds = yield* operationStore.removeByNamespace(namespace);\n if (toolIds.length > 0) {\n yield* ctx.tools.unregister(toolIds);\n }\n yield* operationStore.removeSource(namespace);\n }),\n\n getSource: (namespace: string) => operationStore.getSource(namespace),\n\n updateSource: (namespace: string, input: GraphqlUpdateSourceInput) =>\n Effect.gen(function* () {\n const existingConfig = yield* operationStore.getSourceConfig(namespace);\n if (!existingConfig) return;\n\n const updatedConfig = {\n ...existingConfig,\n ...(input.endpoint !== undefined ? { endpoint: input.endpoint } : {}),\n ...(input.headers !== undefined\n ? { headers: input.headers as Record<string, HeaderValueValue> }\n : {}),\n };\n\n const newInvocationConfig = new InvocationConfig({\n endpoint: updatedConfig.endpoint,\n headers: (updatedConfig.headers ?? {}) as Record<string, HeaderValueValue>,\n });\n\n const toolIds = yield* operationStore.listByNamespace(namespace);\n for (const toolId of toolIds) {\n const entry = yield* operationStore.get(toolId);\n if (entry) {\n yield* operationStore.put(\n toolId,\n namespace,\n entry.binding,\n newInvocationConfig,\n );\n }\n }\n\n const sources = yield* operationStore.listSources();\n const existingMeta = sources.find((s) => s.namespace === namespace);\n\n yield* operationStore.putSource({\n namespace,\n name: existingMeta?.name ?? namespace,\n config: updatedConfig,\n });\n }),\n },\n\n close: () => runtimeTools.close(),\n };\n }),\n });\n};\n"],"mappings":";AAAA,SAAS,MAAM,cAAc;AAGtB,IAAM,4BAAN,cAAwC,OAAO,YAAuC;AAAA,EAC3F;AAAA,EACA;AAAA,IACE,SAAS,OAAO;AAAA,EAClB;AACF,EAAE;AAAC;AAEI,IAAM,yBAAN,cAAqC,OAAO,YAAoC;AAAA,EACrF;AAAA,EACA;AAAA,IACE,SAAS,OAAO;AAAA,EAClB;AACF,EAAE;AAAC;AAEI,IAAM,yBAAN,cAAqC,KAAK,YAAY,wBAAwB,EAIlF;AAAC;;;ACrBJ,SAAS,cAAc;AACvB,SAAS,YAAY,yBAAyB;AAQ9C,IAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0HrB,IAAM,aAAa,OAAO,GAAG,oBAAoB,EAAE,WACxD,UACA,SACA;AACA,QAAM,SAAS,OAAO,WAAW;AAEjC,MAAI,UAAU,kBAAkB,KAAK,QAAQ,EAAE;AAAA,IAC7C,kBAAkB,UAAU,gBAAgB,kBAAkB;AAAA,IAC9D,kBAAkB,eAAe;AAAA,MAC/B,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,MAAI,SAAS;AACX,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ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C;AAAA,UAEH,WAAW,CAAC,cAAsB,eAAe,UAAU,SAAS;AAAA,UAEpE,cAAc,CAAC,WAAmB,UAChCA,QAAO,IAAI,aAAa;AACtB,kBAAM,iBAAiB,OAAO,eAAe,gBAAgB,SAAS;AACtE,gBAAI,CAAC,eAAgB;AAErB,kBAAM,gBAAgB;AAAA,cACpB,GAAG;AAAA,cACH,GAAI,MAAM,aAAa,SAAY,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;AAAA,cACnE,GAAI,MAAM,YAAY,SAClB,EAAE,SAAS,MAAM,QAA4C,IAC7D,CAAC;AAAA,YACP;AAEA,kBAAM,sBAAsB,IAAI,iBAAiB;AAAA,cAC/C,UAAU,cAAc;AAAA,cACxB,SAAU,cAAc,WAAW,CAAC;AAAA,YACtC,CAAC;AAED,kBAAM,UAAU,OAAO,eAAe,gBAAgB,SAAS;AAC/D,uBAAW,UAAU,SAAS;AAC5B,oBAAM,QAAQ,OAAO,eAAe,IAAI,MAAM;AAC9C,kBAAI,OAAO;AACT,uBAAO,eAAe;AAAA,kBACpB;AAAA,kBACA;AAAA,kBACA,MAAM;AAAA,kBACN;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAEA,kBAAM,UAAU,OAAO,eAAe,YAAY;AAClD,kBAAM,eAAe,QAAQ,KAAK,CAAC,MAAM,EAAE,cAAc,SAAS;AAElE,mBAAO,eAAe,UAAU;AAAA,cAC9B;AAAA,cACA,MAAM,cAAc,QAAQ;AAAA,cAC5B,QAAQ;AAAA,YACV,CAAC;AAAA,UACH,CAAC;AAAA,QACL;AAAA,QAEA,OAAO,MAAM,aAAa,MAAM;AAAA,MAClC;AAAA,IACF,CAAC;AAAA,EACL,CAAC;AACH;","names":["Schema","Effect","Effect","Effect","Option","HttpClient","HttpClientRequest","Effect","HttpClient","HttpClientRequest","Option","Effect","Schema","Schema","Schema","Schema","Effect","Effect","Option","Schema","Schema","formatTypeRef","unwrapTypeName","Option","Effect"]}
|