@lssm/lib.contracts 0.0.0-canary-20251217052941 → 0.0.0-canary-20251217060433
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/app-config/app-config.feature.d.ts +11 -0
- package/dist/app-config/branding.d.ts +55 -0
- package/dist/app-config/contracts.d.ts +244 -0
- package/dist/app-config/docs/app-config.docblock.d.ts +6 -0
- package/dist/app-config/events.d.ts +122 -0
- package/dist/app-config/index.d.ts +9 -0
- package/dist/app-config/lifecycle-contracts.d.ts +382 -0
- package/dist/app-config/lifecycle.d.ts +27 -0
- package/dist/app-config/runtime.d.ts +114 -0
- package/dist/app-config/spec.d.ts +175 -0
- package/dist/app-config/validation.d.ts +47 -0
- package/dist/capabilities/docs/capabilities.docblock.d.ts +6 -0
- package/dist/capabilities/openbanking.d.ts +9 -0
- package/dist/capabilities.d.ts +48 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/react/drivers/rn-reusables.d.ts +22 -0
- package/dist/client/react/drivers/shadcn.d.ts +12 -0
- package/dist/client/react/feature-render.d.ts +19 -0
- package/dist/client/react/form-render.d.ts +91 -0
- package/dist/client/react/index.d.ts +5 -0
- package/dist/contract-registry/index.d.ts +3 -0
- package/dist/contract-registry/schemas.d.ts +124 -0
- package/dist/contract-registry/types.d.ts +46 -0
- package/dist/contracts-adapter-hydration.d.ts +15 -0
- package/dist/contracts-adapter-input.d.ts +10 -0
- package/dist/data-views/docs/data-views.docblock.d.ts +6 -0
- package/dist/data-views/query-generator.d.ts +39 -0
- package/dist/data-views/runtime.d.ts +26 -0
- package/dist/data-views.d.ts +131 -0
- package/dist/docs/PUBLISHING.docblock.d.ts +6 -0
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.d.ts +6 -0
- package/dist/docs/index.d.ts +6 -0
- package/dist/docs/meta.docs.d.ts +6 -0
- package/dist/docs/presentations.d.ts +33 -0
- package/dist/docs/registry.d.ts +24 -0
- package/dist/docs/tech/PHASE_1_QUICKSTART.docblock.d.ts +6 -0
- package/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.d.ts +6 -0
- package/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.d.ts +6 -0
- package/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.d.ts +6 -0
- package/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.d.ts +6 -0
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/README.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/create-subscription.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/graphql-typed-outputs.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/migrations.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/openapi-export.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/overlays.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/tests.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/themes.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.d.ts +6 -0
- package/dist/docs/tech/lifecycle-stage-system.docblock.d.ts +6 -0
- package/dist/docs/tech/llm/llm-integration.docblock.d.ts +7 -0
- package/dist/docs/tech/mcp-endpoints.docblock.d.ts +6 -0
- package/dist/docs/tech/presentation-runtime.docblock.d.ts +6 -0
- package/dist/docs/tech/schema/README.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/learning-events.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/learning-journeys.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/platform-admin-panel.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/project-access-teams.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/project-routing.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/team-invitations.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/workspace-ops.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/workspaces.docblock.d.ts +6 -0
- package/dist/docs/tech/telemetry-ingest.docblock.d.ts +6 -0
- package/dist/docs/tech/templates/runtime.docblock.d.ts +6 -0
- package/dist/docs/tech/vscode-extension.docblock.d.ts +6 -0
- package/dist/docs/tech/workflows/overview.docblock.d.ts +6 -0
- package/dist/docs/tech-contracts.docs.d.ts +6 -0
- package/dist/docs/types.d.ts +41 -0
- package/dist/events.d.ts +47 -0
- package/dist/experiments/docs/experiments.docblock.d.ts +6 -0
- package/dist/experiments/evaluator.d.ts +37 -0
- package/dist/experiments/spec-resolver.d.ts +16 -0
- package/dist/experiments/spec.d.ts +89 -0
- package/dist/features.d.ts +96 -0
- package/dist/forms/docs/forms.docblock.d.ts +6 -0
- package/dist/forms.d.ts +258 -0
- package/dist/index.d.ts +127 -0
- package/dist/install.d.ts +76 -0
- package/dist/integrations/binding.d.ts +17 -0
- package/dist/integrations/connection.d.ts +51 -0
- package/dist/integrations/contracts.d.ts +435 -0
- package/dist/integrations/docs/integrations.docblock.d.ts +6 -0
- package/dist/integrations/health.d.ts +21 -0
- package/dist/integrations/index.d.ts +34 -0
- package/dist/integrations/openbanking/contracts/accounts.d.ts +287 -0
- package/dist/integrations/openbanking/contracts/balances.d.ts +163 -0
- package/dist/integrations/openbanking/contracts/index.d.ts +10 -0
- package/dist/integrations/openbanking/contracts/transactions.d.ts +211 -0
- package/dist/integrations/openbanking/guards.d.ts +12 -0
- package/dist/integrations/openbanking/models.d.ts +228 -0
- package/dist/integrations/openbanking/openbanking.feature.d.ts +11 -0
- package/dist/integrations/openbanking/telemetry.d.ts +15 -0
- package/dist/integrations/providers/calendar.d.ts +78 -0
- package/dist/integrations/providers/elevenlabs.d.ts +7 -0
- package/dist/integrations/providers/email.d.ts +86 -0
- package/dist/integrations/providers/embedding.d.ts +24 -0
- package/dist/integrations/providers/gcs-storage.d.ts +7 -0
- package/dist/integrations/providers/gmail.d.ts +7 -0
- package/dist/integrations/providers/google-calendar.d.ts +7 -0
- package/dist/integrations/providers/impls/elevenlabs-voice.d.ts +20 -0
- package/dist/integrations/providers/impls/gcs-storage.d.ts +24 -0
- package/dist/integrations/providers/impls/gmail-inbound.d.ts +26 -0
- package/dist/integrations/providers/impls/gmail-outbound.d.ts +18 -0
- package/dist/integrations/providers/impls/google-calendar.d.ts +23 -0
- package/dist/integrations/providers/impls/index.d.ts +15 -0
- package/dist/integrations/providers/impls/mistral-embedding.d.ts +23 -0
- package/dist/integrations/providers/impls/mistral-llm.d.ts +31 -0
- package/dist/integrations/providers/impls/postmark-email.d.ts +19 -0
- package/dist/integrations/providers/impls/powens-client.d.ts +124 -0
- package/dist/integrations/providers/impls/powens-openbanking.d.ts +27 -0
- package/dist/integrations/providers/impls/provider-factory.d.ts +26 -0
- package/dist/integrations/providers/impls/qdrant-vector.d.ts +24 -0
- package/dist/integrations/providers/impls/stripe-payments.d.ts +28 -0
- package/dist/integrations/providers/impls/twilio-sms.d.ts +20 -0
- package/dist/integrations/providers/index.d.ts +22 -0
- package/dist/integrations/providers/llm.d.ts +82 -0
- package/dist/integrations/providers/mistral.d.ts +7 -0
- package/dist/integrations/providers/openbanking.d.ts +128 -0
- package/dist/integrations/providers/payments.d.ts +109 -0
- package/dist/integrations/providers/postmark.d.ts +7 -0
- package/dist/integrations/providers/powens.d.ts +7 -0
- package/dist/integrations/providers/qdrant.d.ts +7 -0
- package/dist/integrations/providers/registry.d.ts +11 -0
- package/dist/integrations/providers/sms.d.ts +34 -0
- package/dist/integrations/providers/storage.d.ts +60 -0
- package/dist/integrations/providers/stripe.d.ts +7 -0
- package/dist/integrations/providers/twilio-sms.d.ts +7 -0
- package/dist/integrations/providers/vector-store.d.ts +43 -0
- package/dist/integrations/providers/voice.d.ts +34 -0
- package/dist/integrations/runtime.d.ts +99 -0
- package/dist/integrations/secrets/aws-secret-manager.d.ts +31 -0
- package/dist/integrations/secrets/env-secret-provider.d.ts +31 -0
- package/dist/integrations/secrets/gcp-secret-manager.d.ts +32 -0
- package/dist/integrations/secrets/gcp-secret-manager.js +1 -1
- package/dist/integrations/secrets/index.d.ts +7 -0
- package/dist/integrations/secrets/manager.d.ts +47 -0
- package/dist/integrations/secrets/provider.d.ts +52 -0
- package/dist/integrations/secrets/scaleway-secret-manager.d.ts +38 -0
- package/dist/integrations/spec.d.ts +79 -0
- package/dist/jobs/define-job.d.ts +18 -0
- package/dist/jobs/gcp-cloud-tasks.d.ts +41 -0
- package/dist/jobs/gcp-pubsub.d.ts +25 -0
- package/dist/jobs/handlers/gmail-sync-handler.d.ts +9 -0
- package/dist/jobs/handlers/index.d.ts +9 -0
- package/dist/jobs/handlers/ping-handler.d.ts +10 -0
- package/dist/jobs/handlers/storage-document-handler.d.ts +12 -0
- package/dist/jobs/index.d.ts +3 -0
- package/dist/jobs/memory-queue.d.ts +18 -0
- package/dist/jobs/queue.d.ts +131 -0
- package/dist/jobs/scaleway-sqs-queue.d.ts +30 -0
- package/dist/jsonschema.d.ts +27 -0
- package/dist/knowledge/binding.d.ts +25 -0
- package/dist/knowledge/contracts.d.ts +316 -0
- package/dist/knowledge/docs/knowledge.docblock.d.ts +6 -0
- package/dist/knowledge/index.d.ts +10 -0
- package/dist/knowledge/ingestion/document-processor.d.ts +24 -0
- package/dist/knowledge/ingestion/embedding-service.d.ts +12 -0
- package/dist/knowledge/ingestion/gmail-adapter.d.ts +18 -0
- package/dist/knowledge/ingestion/index.d.ts +6 -0
- package/dist/knowledge/ingestion/storage-adapter.d.ts +15 -0
- package/dist/knowledge/ingestion/vector-indexer.d.ts +18 -0
- package/dist/knowledge/query/index.d.ts +2 -0
- package/dist/knowledge/query/service.d.ts +29 -0
- package/dist/knowledge/runtime.d.ts +32 -0
- package/dist/knowledge/source.d.ts +32 -0
- package/dist/knowledge/spaces/email-threads.d.ts +7 -0
- package/dist/knowledge/spaces/financial-docs.d.ts +7 -0
- package/dist/knowledge/spaces/financial-overview.d.ts +7 -0
- package/dist/knowledge/spaces/index.d.ts +7 -0
- package/dist/knowledge/spaces/product-canon.d.ts +7 -0
- package/dist/knowledge/spaces/support-faq.d.ts +7 -0
- package/dist/knowledge/spaces/uploaded-docs.d.ts +7 -0
- package/dist/knowledge/spec.d.ts +52 -0
- package/dist/llm/exporters.d.ts +67 -0
- package/dist/llm/index.d.ts +4 -0
- package/dist/llm/prompts.d.ts +51 -0
- package/dist/llm/types.d.ts +213 -0
- package/dist/markdown.d.ts +21 -0
- package/dist/migrations.d.ts +52 -0
- package/dist/onboarding-base.d.ts +137 -0
- package/dist/openapi.d.ts +31 -0
- package/dist/openbanking/docs/openbanking.docblock.d.ts +6 -0
- package/dist/ownership.d.ts +75 -0
- package/dist/policy/docs/policy.docblock.d.ts +6 -0
- package/dist/policy/engine.d.ts +39 -0
- package/dist/policy/opa-adapter.d.ts +45 -0
- package/dist/policy/spec.d.ts +114 -0
- package/dist/presentations/docs/presentations-conventions.docblock.d.ts +6 -0
- package/dist/presentations.backcompat.d.ts +7 -0
- package/dist/presentations.d.ts +98 -0
- package/dist/presentations.v2.d.ts +114 -0
- package/dist/prompt.d.ts +60 -0
- package/dist/promptRegistry.d.ts +15 -0
- package/dist/regenerator/adapters.d.ts +19 -0
- package/dist/regenerator/docs/regenerator.docblock.d.ts +6 -0
- package/dist/regenerator/executor.d.ts +70 -0
- package/dist/regenerator/index.d.ts +7 -0
- package/dist/regenerator/service.d.ts +33 -0
- package/dist/regenerator/sinks.d.ts +26 -0
- package/dist/regenerator/types.d.ts +107 -0
- package/dist/regenerator/utils.d.ts +9 -0
- package/dist/registry.d.ts +73 -0
- package/dist/resources.d.ts +64 -0
- package/dist/schema-to-markdown.d.ts +54 -0
- package/dist/server/graphql-pothos.d.ts +27 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/mcp/createMcpServer.d.ts +15 -0
- package/dist/server/mcp/mcpTypes.d.ts +29 -0
- package/dist/server/mcp/registerPresentations.d.ts +7 -0
- package/dist/server/mcp/registerPrompts.d.ts +8 -0
- package/dist/server/mcp/registerResources.d.ts +8 -0
- package/dist/server/mcp/registerTools.d.ts +8 -0
- package/dist/server/provider-mcp.d.ts +2 -0
- package/dist/server/rest-elysia.d.ts +40 -0
- package/dist/server/rest-express.d.ts +16 -0
- package/dist/server/rest-generic.d.ts +32 -0
- package/dist/server/rest-next-app.d.ts +35 -0
- package/dist/server/rest-next-mcp.d.ts +11 -0
- package/dist/server/rest-next-pages.d.ts +9 -0
- package/dist/spec.d.ts +195 -0
- package/dist/telemetry/anomaly.d.ts +27 -0
- package/dist/telemetry/docs/telemetry.docblock.d.ts +6 -0
- package/dist/telemetry/index.d.ts +4 -0
- package/dist/telemetry/spec.d.ts +98 -0
- package/dist/telemetry/tracker.d.ts +51 -0
- package/dist/tests/index.d.ts +3 -0
- package/dist/tests/runner.d.ts +43 -0
- package/dist/tests/spec.d.ts +89 -0
- package/dist/themes.d.ts +55 -0
- package/dist/translations/catalog.d.ts +28 -0
- package/dist/translations/tenant.d.ts +15 -0
- package/dist/types/all.d.ts +60 -0
- package/dist/types.d.ts +88 -0
- package/dist/workflow/adapters/db-adapter.d.ts +34 -0
- package/dist/workflow/adapters/file-adapter.d.ts +14 -0
- package/dist/workflow/adapters/index.d.ts +4 -0
- package/dist/workflow/adapters/memory-store.d.ts +18 -0
- package/dist/workflow/expression.d.ts +9 -0
- package/dist/workflow/index.d.ts +10 -0
- package/dist/workflow/runner.d.ts +74 -0
- package/dist/workflow/sla-monitor.d.ts +20 -0
- package/dist/workflow/spec.d.ts +99 -0
- package/dist/workflow/state.d.ts +35 -0
- package/dist/workflow/validation.d.ts +28 -0
- package/package.json +250 -250
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { OwnerShipMeta } from "./ownership.js";
|
|
2
|
+
import { DocId } from "./docs/registry.js";
|
|
3
|
+
import { AnySchemaModel } from "@lssm/lib.schema";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { BlockConfig } from "@blocknote/core";
|
|
6
|
+
|
|
7
|
+
//#region src/presentations.v2.d.ts
|
|
8
|
+
/** Supported render targets for the transform engine and descriptors. */
|
|
9
|
+
type PresentationTarget = 'react' | 'markdown' | 'application/json' | 'application/xml';
|
|
10
|
+
interface PresentationV2Meta extends Partial<OwnerShipMeta> {
|
|
11
|
+
/** Fully-qualified presentation name (e.g., "sigil.auth.webauth_tabs_v2"). */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Version of this descriptor. Increment on breaking changes. */
|
|
14
|
+
version: number;
|
|
15
|
+
/** Human-readable description for docs/a11y. Required by validators. */
|
|
16
|
+
description?: string;
|
|
17
|
+
/** Optional doc block id for this presentation. */
|
|
18
|
+
docId?: DocId;
|
|
19
|
+
}
|
|
20
|
+
/** React component presentation source. */
|
|
21
|
+
interface PresentationSourceComponentReact {
|
|
22
|
+
/** Source marker for React component presentations. */
|
|
23
|
+
type: 'component';
|
|
24
|
+
/** Framework for the component source (currently only 'react'). */
|
|
25
|
+
framework: 'react';
|
|
26
|
+
/** Component key resolved by host `componentMap`. */
|
|
27
|
+
componentKey: string;
|
|
28
|
+
/** Optional props schema to validate against. */
|
|
29
|
+
props?: AnySchemaModel;
|
|
30
|
+
}
|
|
31
|
+
/** BlockNoteJS document presentation source. */
|
|
32
|
+
interface PresentationSourceBlocknotejs {
|
|
33
|
+
/** Source marker for BlockNoteJS document presentations. */
|
|
34
|
+
type: 'blocknotejs';
|
|
35
|
+
/** BlockNoteJS JSON document. */
|
|
36
|
+
docJson: unknown;
|
|
37
|
+
/** Optional BlockNote config to guide rendering. */
|
|
38
|
+
blockConfig?: BlockConfig;
|
|
39
|
+
}
|
|
40
|
+
type PresentationSource = PresentationSourceComponentReact | PresentationSourceBlocknotejs;
|
|
41
|
+
/**
|
|
42
|
+
* Normalized presentation descriptor decoupled from framework/adapters.
|
|
43
|
+
* Renderers and validators are provided via TransformEngine.
|
|
44
|
+
*/
|
|
45
|
+
interface PresentationDescriptorV2 {
|
|
46
|
+
meta: PresentationV2Meta;
|
|
47
|
+
policy?: {
|
|
48
|
+
flags?: string[];
|
|
49
|
+
pii?: string[];
|
|
50
|
+
};
|
|
51
|
+
source: PresentationSource;
|
|
52
|
+
targets: PresentationTarget[];
|
|
53
|
+
}
|
|
54
|
+
interface RenderContext {
|
|
55
|
+
/** Optional locale hint (i18n). */
|
|
56
|
+
locale?: string;
|
|
57
|
+
/** Enabled feature flags to drive conditional rendering. */
|
|
58
|
+
featureFlags?: string[];
|
|
59
|
+
/** Redaction hook for custom PII handling. */
|
|
60
|
+
redact?: (path: string, value: unknown) => unknown;
|
|
61
|
+
/** Optional data for schema-driven rendering (arrays or objects). */
|
|
62
|
+
data?: unknown;
|
|
63
|
+
/** Optional async data fetcher for renderers that need to load data on demand. */
|
|
64
|
+
fetchData?: () => Promise<unknown>;
|
|
65
|
+
}
|
|
66
|
+
interface PresentationRenderer<TOut> {
|
|
67
|
+
target: PresentationTarget;
|
|
68
|
+
render: (desc: PresentationDescriptorV2, ctx?: RenderContext) => Promise<TOut>;
|
|
69
|
+
}
|
|
70
|
+
interface PresentationValidator {
|
|
71
|
+
validate: (desc: PresentationDescriptorV2, target: PresentationTarget, ctx?: RenderContext) => Promise<void> | void;
|
|
72
|
+
}
|
|
73
|
+
declare class TransformEngine {
|
|
74
|
+
private renderers;
|
|
75
|
+
private validators;
|
|
76
|
+
register<TOut>(renderer: PresentationRenderer<TOut>): this;
|
|
77
|
+
/**
|
|
78
|
+
* Register a renderer that will be tried BEFORE existing renderers for the same target.
|
|
79
|
+
* Useful for custom renderers that should take priority over default ones.
|
|
80
|
+
*/
|
|
81
|
+
prependRegister<TOut>(renderer: PresentationRenderer<TOut>): this;
|
|
82
|
+
addValidator(v: PresentationValidator): this;
|
|
83
|
+
render<TOut = unknown>(target: PresentationTarget, desc: PresentationDescriptorV2, ctx?: RenderContext): Promise<TOut>;
|
|
84
|
+
}
|
|
85
|
+
/** Create a TransformEngine instance with default markdown/json/xml renderers. */
|
|
86
|
+
declare function createDefaultTransformEngine(): TransformEngine;
|
|
87
|
+
/** Serializable render descriptor for React hosts. */
|
|
88
|
+
type ReactRenderDescriptor = {
|
|
89
|
+
kind: 'react_component';
|
|
90
|
+
componentKey: string;
|
|
91
|
+
props?: Record<string, unknown>;
|
|
92
|
+
} | {
|
|
93
|
+
kind: 'blocknotejs';
|
|
94
|
+
docJson: unknown;
|
|
95
|
+
blockConfig?: BlockConfig;
|
|
96
|
+
};
|
|
97
|
+
/** Register a default React target renderer that returns a serializable descriptor. */
|
|
98
|
+
declare function registerDefaultReactRenderer(engine: TransformEngine): TransformEngine;
|
|
99
|
+
/**
|
|
100
|
+
* Add basic validators (e.g., meta.description presence) to the engine.
|
|
101
|
+
*/
|
|
102
|
+
declare function registerBasicValidation(engine: TransformEngine): TransformEngine;
|
|
103
|
+
/**
|
|
104
|
+
* Component map type for React rendering.
|
|
105
|
+
*/
|
|
106
|
+
type ComponentMap = Record<string, React.ComponentType<any>>;
|
|
107
|
+
/**
|
|
108
|
+
* Register a React-to-markdown renderer that renders React components to HTML
|
|
109
|
+
* and converts them to markdown using turndown.
|
|
110
|
+
* This renderer takes priority over the default metadata-only renderer.
|
|
111
|
+
*/
|
|
112
|
+
declare function registerReactToMarkdownRenderer(engine: TransformEngine, componentMap: ComponentMap): TransformEngine;
|
|
113
|
+
//#endregion
|
|
114
|
+
export { ComponentMap, PresentationDescriptorV2, PresentationRenderer, PresentationSource, PresentationSourceBlocknotejs, PresentationSourceComponentReact, PresentationTarget, PresentationV2Meta, PresentationValidator, ReactRenderDescriptor, RenderContext, TransformEngine, createDefaultTransformEngine, registerBasicValidation, registerDefaultReactRenderer, registerReactToMarkdownRenderer };
|
package/dist/prompt.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as z$1 from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/prompt.d.ts
|
|
4
|
+
type PromptStability = 'experimental' | 'beta' | 'stable' | 'deprecated';
|
|
5
|
+
/** Parameter definition for a prompt argument. */
|
|
6
|
+
interface PromptArg {
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
schema: z$1.ZodType;
|
|
11
|
+
completeWith?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Rendered content part for a prompt. Clients (MCP) can fetch referenced resources.
|
|
15
|
+
*/
|
|
16
|
+
type PromptContentPart = {
|
|
17
|
+
type: 'text';
|
|
18
|
+
text: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'resource';
|
|
21
|
+
uri: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
};
|
|
24
|
+
/** Prompt metadata for discoverability and governance. */
|
|
25
|
+
interface PromptMeta {
|
|
26
|
+
name: string;
|
|
27
|
+
version: number;
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
tags?: string[];
|
|
31
|
+
stability?: PromptStability;
|
|
32
|
+
owners?: string[];
|
|
33
|
+
}
|
|
34
|
+
/** Policy constraints for prompts (flags, PII paths, rate limits). */
|
|
35
|
+
interface PromptPolicy {
|
|
36
|
+
flags?: string[];
|
|
37
|
+
pii?: string[];
|
|
38
|
+
rateLimit?: {
|
|
39
|
+
rpm: number;
|
|
40
|
+
key: 'user' | 'org' | 'global';
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Full prompt specification including args schema and render function. */
|
|
44
|
+
interface PromptSpec<I extends z$1.ZodType> {
|
|
45
|
+
meta: PromptMeta;
|
|
46
|
+
args: PromptArg[];
|
|
47
|
+
input: I;
|
|
48
|
+
policy?: PromptPolicy;
|
|
49
|
+
/** Render MCP-friendly content parts. DO NOT perform side effects here. */
|
|
50
|
+
render: (args: z$1.infer<I>, ctx: {
|
|
51
|
+
userId?: string | null;
|
|
52
|
+
orgId?: string | null;
|
|
53
|
+
locale?: string;
|
|
54
|
+
link: (template: string, vars: Record<string, string | number>) => string;
|
|
55
|
+
}) => Promise<PromptContentPart[]>;
|
|
56
|
+
}
|
|
57
|
+
/** Identity helper that preserves generic inference when declaring prompts. */
|
|
58
|
+
declare function definePrompt<I extends z$1.ZodType>(spec: PromptSpec<I>): PromptSpec<I>;
|
|
59
|
+
//#endregion
|
|
60
|
+
export { PromptArg, PromptContentPart, PromptMeta, PromptPolicy, PromptSpec, PromptStability, definePrompt };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PromptSpec } from "./prompt.js";
|
|
2
|
+
import * as z$1 from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/promptRegistry.d.ts
|
|
5
|
+
declare class PromptRegistry {
|
|
6
|
+
private prompts;
|
|
7
|
+
/** Register a prompt. Throws on duplicate name+version. */
|
|
8
|
+
register<I extends z$1.ZodType>(p: PromptSpec<I>): this;
|
|
9
|
+
/** List all registered prompts. */
|
|
10
|
+
list(): PromptSpec<any>[];
|
|
11
|
+
/** Get prompt by name; when version omitted, returns highest version. */
|
|
12
|
+
get(name: string, version?: number): PromptSpec<any> | undefined;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { PromptRegistry };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BehaviorSignal, ErrorSignal, RegenerationContext, TelemetrySignal } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/regenerator/adapters.d.ts
|
|
4
|
+
interface TelemetrySignalProvider {
|
|
5
|
+
pollTelemetry(context: RegenerationContext, since: Date, until: Date): Promise<TelemetrySignal[]>;
|
|
6
|
+
}
|
|
7
|
+
interface ErrorSignalProvider {
|
|
8
|
+
pollErrors(context: RegenerationContext, since: Date, until: Date): Promise<ErrorSignal[]>;
|
|
9
|
+
}
|
|
10
|
+
interface BehaviorSignalProvider {
|
|
11
|
+
pollBehavior(context: RegenerationContext, since: Date, until: Date): Promise<BehaviorSignal[]>;
|
|
12
|
+
}
|
|
13
|
+
interface SignalAdapters {
|
|
14
|
+
telemetry?: TelemetrySignalProvider;
|
|
15
|
+
errors?: ErrorSignalProvider;
|
|
16
|
+
behavior?: BehaviorSignalProvider;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { BehaviorSignalProvider, ErrorSignalProvider, SignalAdapters, TelemetrySignalProvider };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ProposalAction, RegenerationContext, SpecChangeProposal } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/regenerator/executor.d.ts
|
|
4
|
+
type ExecutionStatus = 'success' | 'skipped' | 'failed';
|
|
5
|
+
interface ActionExecutionResult {
|
|
6
|
+
index: number;
|
|
7
|
+
action: ProposalAction;
|
|
8
|
+
status: ExecutionStatus;
|
|
9
|
+
startedAt: Date;
|
|
10
|
+
finishedAt: Date;
|
|
11
|
+
reason?: string;
|
|
12
|
+
error?: Error;
|
|
13
|
+
output?: unknown;
|
|
14
|
+
}
|
|
15
|
+
interface ProposalExecutionResult {
|
|
16
|
+
proposalId: string;
|
|
17
|
+
contextId: string;
|
|
18
|
+
startedAt: Date;
|
|
19
|
+
finishedAt: Date;
|
|
20
|
+
status: 'success' | 'partial' | 'failed';
|
|
21
|
+
actions: ActionExecutionResult[];
|
|
22
|
+
}
|
|
23
|
+
type UpdateBlueprintAction = Extract<ProposalAction, {
|
|
24
|
+
kind: 'update_blueprint';
|
|
25
|
+
}>;
|
|
26
|
+
type UpdateTenantConfigAction = Extract<ProposalAction, {
|
|
27
|
+
kind: 'update_tenant_config';
|
|
28
|
+
}>;
|
|
29
|
+
type RunTestsAction = Extract<ProposalAction, {
|
|
30
|
+
kind: 'run_tests';
|
|
31
|
+
}>;
|
|
32
|
+
type RunMigrationsAction = Extract<ProposalAction, {
|
|
33
|
+
kind: 'run_migrations';
|
|
34
|
+
}>;
|
|
35
|
+
type TriggerRegenerationAction = Extract<ProposalAction, {
|
|
36
|
+
kind: 'trigger_regeneration';
|
|
37
|
+
}>;
|
|
38
|
+
interface BlueprintUpdater {
|
|
39
|
+
applyBlueprintUpdate(context: RegenerationContext, proposal: SpecChangeProposal, action: UpdateBlueprintAction): Promise<unknown>;
|
|
40
|
+
}
|
|
41
|
+
interface TenantConfigUpdater {
|
|
42
|
+
applyTenantConfigUpdate(context: RegenerationContext, proposal: SpecChangeProposal, action: UpdateTenantConfigAction): Promise<unknown>;
|
|
43
|
+
}
|
|
44
|
+
interface TestExecutor {
|
|
45
|
+
runTests(context: RegenerationContext, proposal: SpecChangeProposal, action: RunTestsAction): Promise<unknown>;
|
|
46
|
+
}
|
|
47
|
+
interface MigrationExecutor {
|
|
48
|
+
runMigrations(context: RegenerationContext, proposal: SpecChangeProposal, action: RunMigrationsAction): Promise<unknown>;
|
|
49
|
+
}
|
|
50
|
+
interface RegenerationTrigger {
|
|
51
|
+
triggerRegeneration(context: RegenerationContext, proposal: SpecChangeProposal, action: TriggerRegenerationAction): Promise<unknown>;
|
|
52
|
+
}
|
|
53
|
+
interface ProposalExecutorOptions {
|
|
54
|
+
dryRun?: boolean;
|
|
55
|
+
}
|
|
56
|
+
interface ProposalExecutorDeps {
|
|
57
|
+
blueprintUpdater?: BlueprintUpdater;
|
|
58
|
+
tenantConfigUpdater?: TenantConfigUpdater;
|
|
59
|
+
testExecutor?: TestExecutor;
|
|
60
|
+
migrationExecutor?: MigrationExecutor;
|
|
61
|
+
regenerationTrigger?: RegenerationTrigger;
|
|
62
|
+
}
|
|
63
|
+
declare class ProposalExecutor {
|
|
64
|
+
private readonly deps;
|
|
65
|
+
constructor(deps?: ProposalExecutorDeps);
|
|
66
|
+
execute(context: RegenerationContext, proposal: SpecChangeProposal, options?: ProposalExecutorOptions): Promise<ProposalExecutionResult>;
|
|
67
|
+
private executeAction;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { ActionExecutionResult, BlueprintUpdater, ExecutionStatus, MigrationExecutor, ProposalExecutionResult, ProposalExecutor, ProposalExecutorDeps, ProposalExecutorOptions, RegenerationTrigger, RunMigrationsAction, RunTestsAction, TenantConfigUpdater, TestExecutor, TriggerRegenerationAction, UpdateBlueprintAction, UpdateTenantConfigAction };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BehaviorSignal, BehaviorSignalEnvelope, ErrorSignal, ErrorSignalEnvelope, ProposalAction, ProposalBlocker, ProposalConfidence, ProposalSink, ProposalTarget, RegenerationContext, RegenerationRule, RegeneratorSignal, SpecChangeProposal, TelemetrySignal, TelemetrySignalEnvelope } from "./types.js";
|
|
2
|
+
import { BehaviorSignalProvider, ErrorSignalProvider, SignalAdapters, TelemetrySignalProvider } from "./adapters.js";
|
|
3
|
+
import { RegeneratorOptions, RegeneratorService } from "./service.js";
|
|
4
|
+
import { ActionExecutionResult, BlueprintUpdater, ExecutionStatus, MigrationExecutor, ProposalExecutionResult, ProposalExecutor, ProposalExecutorDeps, ProposalExecutorOptions, RegenerationTrigger, RunMigrationsAction, RunTestsAction, TenantConfigUpdater, TestExecutor, TriggerRegenerationAction, UpdateBlueprintAction, UpdateTenantConfigAction } from "./executor.js";
|
|
5
|
+
import { behaviorToEnvelope, errorToEnvelope, telemetryToEnvelope } from "./utils.js";
|
|
6
|
+
import { ExecutorProposalSink, ExecutorResultPayload, ExecutorSinkLogger, ExecutorSinkOptions } from "./sinks.js";
|
|
7
|
+
export { ActionExecutionResult, BehaviorSignal, BehaviorSignalEnvelope, BehaviorSignalProvider, BlueprintUpdater, ErrorSignal, ErrorSignalEnvelope, ErrorSignalProvider, ExecutionStatus, ExecutorProposalSink, ExecutorResultPayload, ExecutorSinkLogger, ExecutorSinkOptions, MigrationExecutor, ProposalAction, ProposalBlocker, ProposalConfidence, ProposalExecutionResult, ProposalExecutor, ProposalExecutorDeps, ProposalExecutorOptions, ProposalSink, ProposalTarget, RegenerationContext, RegenerationRule, RegenerationTrigger, RegeneratorOptions, RegeneratorService, RegeneratorSignal, RunMigrationsAction, RunTestsAction, SignalAdapters, SpecChangeProposal, TelemetrySignal, TelemetrySignalEnvelope, TelemetrySignalProvider, TenantConfigUpdater, TestExecutor, TriggerRegenerationAction, UpdateBlueprintAction, UpdateTenantConfigAction, behaviorToEnvelope, errorToEnvelope, telemetryToEnvelope };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ProposalSink, RegenerationContext, RegenerationRule } from "./types.js";
|
|
2
|
+
import { SignalAdapters } from "./adapters.js";
|
|
3
|
+
|
|
4
|
+
//#region src/regenerator/service.d.ts
|
|
5
|
+
interface RegeneratorOptions {
|
|
6
|
+
contexts: RegenerationContext[];
|
|
7
|
+
adapters: SignalAdapters;
|
|
8
|
+
rules: RegenerationRule[];
|
|
9
|
+
sink: ProposalSink;
|
|
10
|
+
pollIntervalMs?: number;
|
|
11
|
+
batchDurationMs?: number;
|
|
12
|
+
clock?: () => Date;
|
|
13
|
+
}
|
|
14
|
+
declare class RegeneratorService {
|
|
15
|
+
private readonly options;
|
|
16
|
+
private readonly contexts;
|
|
17
|
+
private readonly lastPoll;
|
|
18
|
+
private timer?;
|
|
19
|
+
private running;
|
|
20
|
+
private readonly pollInterval;
|
|
21
|
+
private readonly batchDuration;
|
|
22
|
+
private readonly clock;
|
|
23
|
+
constructor(options: RegeneratorOptions);
|
|
24
|
+
start(): void;
|
|
25
|
+
stop(): void;
|
|
26
|
+
runOnce(): Promise<void>;
|
|
27
|
+
private tick;
|
|
28
|
+
private evaluateContext;
|
|
29
|
+
private collectSignals;
|
|
30
|
+
private flushProposals;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { RegeneratorOptions, RegeneratorService };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ProposalSink, RegenerationContext, SpecChangeProposal } from "./types.js";
|
|
2
|
+
import { ProposalExecutionResult, ProposalExecutor } from "./executor.js";
|
|
3
|
+
|
|
4
|
+
//#region src/regenerator/sinks.d.ts
|
|
5
|
+
interface ExecutorResultPayload {
|
|
6
|
+
context: RegenerationContext;
|
|
7
|
+
proposal: SpecChangeProposal;
|
|
8
|
+
result: ProposalExecutionResult;
|
|
9
|
+
}
|
|
10
|
+
interface ExecutorSinkLogger {
|
|
11
|
+
info?: (message: string, meta?: Record<string, unknown>) => void;
|
|
12
|
+
error?: (message: string, error: Error, meta?: Record<string, unknown>) => void;
|
|
13
|
+
}
|
|
14
|
+
interface ExecutorSinkOptions {
|
|
15
|
+
dryRun?: boolean;
|
|
16
|
+
onResult?: (payload: ExecutorResultPayload) => void | Promise<void>;
|
|
17
|
+
logger?: ExecutorSinkLogger;
|
|
18
|
+
}
|
|
19
|
+
declare class ExecutorProposalSink implements ProposalSink {
|
|
20
|
+
private readonly executor;
|
|
21
|
+
private readonly options;
|
|
22
|
+
constructor(executor: ProposalExecutor, options?: ExecutorSinkOptions);
|
|
23
|
+
submit(context: RegenerationContext, proposal: SpecChangeProposal): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { ExecutorProposalSink, ExecutorResultPayload, ExecutorSinkLogger, ExecutorSinkOptions };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { TelemetrySpec } from "../telemetry/spec.js";
|
|
2
|
+
import { AppBlueprintSpec, TenantAppConfig } from "../app-config/spec.js";
|
|
3
|
+
import { ResolvedAppConfig } from "../app-config/runtime.js";
|
|
4
|
+
|
|
5
|
+
//#region src/regenerator/types.d.ts
|
|
6
|
+
type RegeneratorSignal = TelemetrySignalEnvelope | ErrorSignalEnvelope | BehaviorSignalEnvelope;
|
|
7
|
+
interface TelemetrySignalEnvelope {
|
|
8
|
+
type: 'telemetry';
|
|
9
|
+
contextId: string;
|
|
10
|
+
signal: TelemetrySignal;
|
|
11
|
+
}
|
|
12
|
+
interface TelemetrySignal {
|
|
13
|
+
eventName: string;
|
|
14
|
+
eventVersion: number;
|
|
15
|
+
count: number;
|
|
16
|
+
windowStart: Date;
|
|
17
|
+
windowEnd: Date;
|
|
18
|
+
anomalyScore?: number;
|
|
19
|
+
classification?: 'normal' | 'warning' | 'critical';
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
telemetrySpec?: TelemetrySpec;
|
|
22
|
+
}
|
|
23
|
+
interface ErrorSignalEnvelope {
|
|
24
|
+
type: 'error';
|
|
25
|
+
contextId: string;
|
|
26
|
+
signal: ErrorSignal;
|
|
27
|
+
}
|
|
28
|
+
interface ErrorSignal {
|
|
29
|
+
id: string;
|
|
30
|
+
classification: 'runtime' | 'policy' | 'workflow' | 'unknown';
|
|
31
|
+
message: string;
|
|
32
|
+
occurredAt: Date;
|
|
33
|
+
count: number;
|
|
34
|
+
metadata?: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
interface BehaviorSignalEnvelope {
|
|
37
|
+
type: 'behavior';
|
|
38
|
+
contextId: string;
|
|
39
|
+
signal: BehaviorSignal;
|
|
40
|
+
}
|
|
41
|
+
interface BehaviorSignal {
|
|
42
|
+
feature: string;
|
|
43
|
+
metric: 'usage' | 'conversion' | 'latency' | 'custom';
|
|
44
|
+
value: number;
|
|
45
|
+
baseline?: number;
|
|
46
|
+
windowStart: Date;
|
|
47
|
+
windowEnd: Date;
|
|
48
|
+
metadata?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
interface SpecChangeProposal {
|
|
51
|
+
id: string;
|
|
52
|
+
title: string;
|
|
53
|
+
summary: string;
|
|
54
|
+
confidence: ProposalConfidence;
|
|
55
|
+
rationale: string[];
|
|
56
|
+
target: ProposalTarget;
|
|
57
|
+
diff?: string;
|
|
58
|
+
actions: ProposalAction[];
|
|
59
|
+
blockers?: ProposalBlocker[];
|
|
60
|
+
createdAt: Date;
|
|
61
|
+
signalIds: string[];
|
|
62
|
+
}
|
|
63
|
+
type ProposalConfidence = 'low' | 'medium' | 'high';
|
|
64
|
+
interface ProposalTarget {
|
|
65
|
+
specType: 'workflow' | 'capability' | 'policy' | 'dataView' | 'telemetry' | 'experiment' | 'theme' | 'unknown';
|
|
66
|
+
reference: {
|
|
67
|
+
name: string;
|
|
68
|
+
version?: number;
|
|
69
|
+
};
|
|
70
|
+
tenantScoped?: boolean;
|
|
71
|
+
}
|
|
72
|
+
type ProposalAction = {
|
|
73
|
+
kind: 'update_blueprint';
|
|
74
|
+
summary: string;
|
|
75
|
+
} | {
|
|
76
|
+
kind: 'update_tenant_config';
|
|
77
|
+
summary: string;
|
|
78
|
+
} | {
|
|
79
|
+
kind: 'run_tests';
|
|
80
|
+
tests: string[];
|
|
81
|
+
} | {
|
|
82
|
+
kind: 'run_migrations';
|
|
83
|
+
migrations: string[];
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'trigger_regeneration';
|
|
86
|
+
summary?: string;
|
|
87
|
+
};
|
|
88
|
+
interface ProposalBlocker {
|
|
89
|
+
description: string;
|
|
90
|
+
kind: 'missing_context' | 'insufficient_data' | 'user_feedback' | 'manual_review';
|
|
91
|
+
}
|
|
92
|
+
interface RegenerationContext {
|
|
93
|
+
id: string;
|
|
94
|
+
blueprint: AppBlueprintSpec;
|
|
95
|
+
tenantConfig: TenantAppConfig;
|
|
96
|
+
resolved: ResolvedAppConfig;
|
|
97
|
+
}
|
|
98
|
+
interface RegenerationRule {
|
|
99
|
+
readonly id: string;
|
|
100
|
+
readonly description: string;
|
|
101
|
+
evaluate(context: RegenerationContext, signals: RegeneratorSignal[]): Promise<SpecChangeProposal[]>;
|
|
102
|
+
}
|
|
103
|
+
interface ProposalSink {
|
|
104
|
+
submit(context: RegenerationContext, proposal: SpecChangeProposal): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { BehaviorSignal, BehaviorSignalEnvelope, ErrorSignal, ErrorSignalEnvelope, ProposalAction, ProposalBlocker, ProposalConfidence, ProposalSink, ProposalTarget, RegenerationContext, RegenerationRule, RegeneratorSignal, SpecChangeProposal, TelemetrySignal, TelemetrySignalEnvelope };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BehaviorSignal, BehaviorSignalEnvelope, ErrorSignal, ErrorSignalEnvelope, TelemetrySignal, TelemetrySignalEnvelope } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/regenerator/utils.d.ts
|
|
4
|
+
type Clock = () => Date;
|
|
5
|
+
declare function telemetryToEnvelope(contextId: string, signal: TelemetrySignal, clock: Clock): TelemetrySignalEnvelope;
|
|
6
|
+
declare function errorToEnvelope(contextId: string, signal: ErrorSignal, clock: Clock): ErrorSignalEnvelope;
|
|
7
|
+
declare function behaviorToEnvelope(contextId: string, signal: BehaviorSignal, clock: Clock): BehaviorSignalEnvelope;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { behaviorToEnvelope, errorToEnvelope, telemetryToEnvelope };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { defaultDocRegistry, docId, registerDocBlocks } from "./docs/registry.js";
|
|
2
|
+
import { ResourceRefDescriptor } from "./resources.js";
|
|
3
|
+
import { ContractSpec } from "./spec.js";
|
|
4
|
+
import { HandlerCtx } from "./types.js";
|
|
5
|
+
import { HandlerFor } from "./install.js";
|
|
6
|
+
import { AnySchemaModel } from "@lssm/lib.schema";
|
|
7
|
+
|
|
8
|
+
//#region src/registry.d.ts
|
|
9
|
+
|
|
10
|
+
type OperationKey = `${string}.v${number}`;
|
|
11
|
+
declare function opKey(name: string, version: number): OperationKey;
|
|
12
|
+
type AnySpec = ContractSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>;
|
|
13
|
+
type AnyHandler = (args: any, ctx: HandlerCtx) => Promise<unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* In-memory registry for ContractSpecs and their bound handlers.
|
|
16
|
+
* Provides validation, policy enforcement, and guarded event emission at execute time.
|
|
17
|
+
*/
|
|
18
|
+
declare class SpecRegistry {
|
|
19
|
+
private specs;
|
|
20
|
+
private handlers;
|
|
21
|
+
/**
|
|
22
|
+
* Registers a ContractSpec definition.
|
|
23
|
+
*
|
|
24
|
+
* @param spec - The contract specification to register.
|
|
25
|
+
* @returns The registry instance for chaining.
|
|
26
|
+
* @throws If a spec with the same name and version is already registered.
|
|
27
|
+
*/
|
|
28
|
+
register<I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>>(spec: ContractSpec<I, O>): this;
|
|
29
|
+
/**
|
|
30
|
+
* Binds a runtime handler implementation to a previously registered spec.
|
|
31
|
+
*
|
|
32
|
+
* @param spec - The spec to bind to.
|
|
33
|
+
* @param handler - The async function implementing the business logic.
|
|
34
|
+
* @returns The registry instance for chaining.
|
|
35
|
+
* @throws If the spec is not found or a handler is already bound.
|
|
36
|
+
*/
|
|
37
|
+
bind<I extends AnySchemaModel, O extends AnySchemaModel | ResourceRefDescriptor<boolean>>(spec: ContractSpec<I, O>, handler: HandlerFor<ContractSpec<I, O>>): this;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves a registered spec by name and version.
|
|
40
|
+
* If version is omitted, returns the highest version found.
|
|
41
|
+
*
|
|
42
|
+
* @param name - Operation name.
|
|
43
|
+
* @param version - (Optional) Specific version.
|
|
44
|
+
*/
|
|
45
|
+
getSpec(name: string, version?: number): AnySpec | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves the bound handler for a spec.
|
|
48
|
+
*/
|
|
49
|
+
getHandler(name: string, version?: number): AnyHandler | undefined;
|
|
50
|
+
/** Iterate all registered specs. */
|
|
51
|
+
listSpecs(): AnySpec[];
|
|
52
|
+
/** Iterate all bound operations (spec+handler). */
|
|
53
|
+
listBound(): {
|
|
54
|
+
spec: AnySpec;
|
|
55
|
+
handler: AnyHandler;
|
|
56
|
+
}[];
|
|
57
|
+
/**
|
|
58
|
+
* Execute an operation by name/version with full runtime protections:
|
|
59
|
+
* 1. Validates input against Zod schema.
|
|
60
|
+
* 2. Enforces policy (Auth, RBAC, Rate Limits) via PDP.
|
|
61
|
+
* 3. Guards event emission to ensure only declared events are sent.
|
|
62
|
+
* 4. Validates output against Zod schema (if applicable).
|
|
63
|
+
* 5. Tracks telemetry (success/failure).
|
|
64
|
+
*
|
|
65
|
+
* @param name - Operation name.
|
|
66
|
+
* @param version - Operation version (optional, defaults to latest).
|
|
67
|
+
* @param rawInput - The raw input payload (e.g. from JSON body).
|
|
68
|
+
* @param ctx - The runtime context (actor, tenant, etc.).
|
|
69
|
+
*/
|
|
70
|
+
execute(name: string, version: number | undefined, rawInput: unknown, ctx: HandlerCtx): Promise<unknown>;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { OperationKey, SpecRegistry, defaultDocRegistry, docId, opKey, registerDocBlocks };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Tag } from "./ownership.js";
|
|
2
|
+
import * as z$1 from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/resources.d.ts
|
|
5
|
+
interface ResourceMeta {
|
|
6
|
+
/** URI scheme, e.g. "content://doc/{id}" or "marketplace://offers/{city}/{tag}" */
|
|
7
|
+
uriTemplate: string;
|
|
8
|
+
/** Human title for discovery */
|
|
9
|
+
title: string;
|
|
10
|
+
/** Short description */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** MIME type for resource body */
|
|
13
|
+
mimeType: string;
|
|
14
|
+
/** Tags for filtering/grouping */
|
|
15
|
+
tags?: Tag[];
|
|
16
|
+
}
|
|
17
|
+
interface ResourceTemplateSpec<I extends z$1.ZodType> {
|
|
18
|
+
meta: ResourceMeta;
|
|
19
|
+
/** Arguments to materialize the URI (zod validates input) */
|
|
20
|
+
input: I;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve returns the resource body and a resolved URI.
|
|
23
|
+
* It MUST be read-only (no side effects).
|
|
24
|
+
*/
|
|
25
|
+
resolve: (args: z$1.infer<I>, ctx: {
|
|
26
|
+
userId?: string | null;
|
|
27
|
+
orgId?: string | null;
|
|
28
|
+
locale?: string;
|
|
29
|
+
}) => Promise<{
|
|
30
|
+
uri: string;
|
|
31
|
+
mimeType?: string;
|
|
32
|
+
data: Uint8Array | string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
declare function defineResourceTemplate<I extends z$1.ZodType>(spec: ResourceTemplateSpec<I>): ResourceTemplateSpec<I>;
|
|
36
|
+
declare class ResourceRegistry {
|
|
37
|
+
private templates;
|
|
38
|
+
register<I extends z$1.ZodType>(tmpl: ResourceTemplateSpec<I>): this;
|
|
39
|
+
listTemplates(): ResourceTemplateSpec<any>[];
|
|
40
|
+
/** Try to match a concrete URI to a template by naive pattern substitution */
|
|
41
|
+
match(uri: string): {
|
|
42
|
+
tmpl: ResourceTemplateSpec<any>;
|
|
43
|
+
params: Record<string, string>;
|
|
44
|
+
} | undefined;
|
|
45
|
+
}
|
|
46
|
+
interface ResourceRefDescriptor<Many extends boolean> {
|
|
47
|
+
kind: 'resource_ref';
|
|
48
|
+
/** URI template, e.g. 'strit://spot/{id}' */
|
|
49
|
+
uriTemplate: string;
|
|
50
|
+
/** Variable name inside result payload to substitute into template; defaults to 'id' */
|
|
51
|
+
varName?: string;
|
|
52
|
+
/** Optional GraphQL type name to use when exposing over GraphQL (e.g., 'Spot') */
|
|
53
|
+
graphQLType: string;
|
|
54
|
+
/** Cardinality: when present and true, the handler returns an array of resources */
|
|
55
|
+
many: Many;
|
|
56
|
+
}
|
|
57
|
+
declare function resourceRef<Many extends boolean>(uriTemplate: string, opts: {
|
|
58
|
+
varName?: string;
|
|
59
|
+
graphQLType: string;
|
|
60
|
+
many: Many;
|
|
61
|
+
}): ResourceRefDescriptor<Many>;
|
|
62
|
+
declare function isResourceRef(x: unknown): x is ResourceRefDescriptor<boolean>;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { ResourceMeta, ResourceRefDescriptor, ResourceRegistry, ResourceTemplateSpec, defineResourceTemplate, isResourceRef, resourceRef };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AnySchemaModel } from "@lssm/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/schema-to-markdown.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for schema-to-markdown generation
|
|
7
|
+
*/
|
|
8
|
+
interface SchemaMarkdownOptions {
|
|
9
|
+
/** Title for the markdown section */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Description to include below the title */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Output format: table for lists, list for simple items, detail for single objects */
|
|
14
|
+
format?: 'table' | 'list' | 'detail' | 'auto';
|
|
15
|
+
/** Maximum number of items to render (for arrays) */
|
|
16
|
+
maxItems?: number;
|
|
17
|
+
/** Only include these fields (if not specified, all fields are included) */
|
|
18
|
+
includeFields?: string[];
|
|
19
|
+
/** Exclude these fields from output */
|
|
20
|
+
excludeFields?: string[];
|
|
21
|
+
/** Custom field labels (field name -> display label) */
|
|
22
|
+
fieldLabels?: Record<string, string>;
|
|
23
|
+
/** Fields to use for summary in list format */
|
|
24
|
+
summaryFields?: string[];
|
|
25
|
+
/** Nesting depth for nested schemas (default: 2) */
|
|
26
|
+
maxDepth?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate markdown from a SchemaModel and data.
|
|
30
|
+
* Automatically detects array vs object data and formats accordingly.
|
|
31
|
+
*/
|
|
32
|
+
declare function schemaToMarkdown(schema: AnySchemaModel, data: unknown, options?: SchemaMarkdownOptions): string;
|
|
33
|
+
/**
|
|
34
|
+
* Generate a markdown table from array data using schema fields as columns.
|
|
35
|
+
*/
|
|
36
|
+
declare function schemaToMarkdownTable(schema: AnySchemaModel, items: unknown[], options?: SchemaMarkdownOptions): string;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a markdown list from array data.
|
|
39
|
+
* Uses summaryFields to create concise list items.
|
|
40
|
+
*/
|
|
41
|
+
declare function schemaToMarkdownList(schema: AnySchemaModel, items: unknown[], options?: SchemaMarkdownOptions): string;
|
|
42
|
+
/**
|
|
43
|
+
* Generate a markdown detail view (key-value pairs) from object data.
|
|
44
|
+
*/
|
|
45
|
+
declare function schemaToMarkdownDetail(schema: AnySchemaModel, item: unknown, options?: SchemaMarkdownOptions): string;
|
|
46
|
+
/**
|
|
47
|
+
* Generate markdown summary statistics for numeric fields in array data.
|
|
48
|
+
*/
|
|
49
|
+
declare function schemaToMarkdownSummary(schema: AnySchemaModel, items: unknown[], options?: {
|
|
50
|
+
numericFields?: string[];
|
|
51
|
+
countByField?: string;
|
|
52
|
+
}): string;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { SchemaMarkdownOptions, schemaToMarkdown, schemaToMarkdownDetail, schemaToMarkdownList, schemaToMarkdownSummary, schemaToMarkdownTable };
|