@lunora/config 1.0.0-alpha.18 → 1.0.0-alpha.19
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/index.d.mts +73 -1
- package/dist/index.d.ts +73 -1
- package/dist/index.mjs +1 -0
- package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +157 -0
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ContainerIR, WorkflowIR, QueueIR } from '@lunora/codegen';
|
|
2
2
|
export type { ContainerIR, WorkflowIR } from '@lunora/codegen';
|
|
3
|
+
import { Writable } from 'node:stream';
|
|
3
4
|
import 'ts-morph';
|
|
4
5
|
export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-DCmwn7zQ.mjs";
|
|
5
6
|
/**
|
|
@@ -65,6 +66,77 @@ interface DiscoverContainerInfoResult {
|
|
|
65
66
|
* (inference).
|
|
66
67
|
*/
|
|
67
68
|
declare const discoverContainerInfo: (projectRoot: string, schemaDirectory: string) => DiscoverContainerInfoResult;
|
|
69
|
+
/** Severity a container output line is surfaced at: `stderr` → `error`, `stdout` → `info`. */
|
|
70
|
+
type ContainerLogLevel = "error" | "info";
|
|
71
|
+
/** One declared container to follow, identified by the names codegen lifts from `defineContainer`. */
|
|
72
|
+
interface ContainerLogSource {
|
|
73
|
+
/** Generated Durable Object class name, e.g. `TranscoderContainer`. Wrangler's dev image is `cloudflare-dev/<lowercased>`. */
|
|
74
|
+
className: string;
|
|
75
|
+
/** The `lunora/containers.ts` export name, e.g. `transcoder` — used as the display tag. */
|
|
76
|
+
exportName: string;
|
|
77
|
+
}
|
|
78
|
+
/** A single line of container output handed back to the caller. */
|
|
79
|
+
interface ContainerLogLine {
|
|
80
|
+
/** `"error"` for the container's stderr, `"info"` for its stdout. */
|
|
81
|
+
level: ContainerLogLevel;
|
|
82
|
+
/** The container's export name (`transcoder`), for tagging the line. */
|
|
83
|
+
name: string;
|
|
84
|
+
/** One output line, with the trailing newline (and any `\r`) stripped. */
|
|
85
|
+
text: string;
|
|
86
|
+
}
|
|
87
|
+
interface ContainerLogStreamOptions {
|
|
88
|
+
/** The declared containers to follow. An empty list yields an inert handle. */
|
|
89
|
+
containers: ReadonlyArray<ContainerLogSource>;
|
|
90
|
+
/** Injected Docker client — defaults to a real lazily-imported `dockerode` instance. Tests pass a stub. */
|
|
91
|
+
docker?: DockerLike;
|
|
92
|
+
/** Called once per container output line. */
|
|
93
|
+
onLine: (line: ContainerLogLine) => void;
|
|
94
|
+
/** Called once when the Docker engine can't be reached (re-armed after it recovers). Defaults to silent. */
|
|
95
|
+
onUnavailable?: (message: string) => void;
|
|
96
|
+
/** Poll interval override, in ms. */
|
|
97
|
+
pollIntervalMs?: number;
|
|
98
|
+
}
|
|
99
|
+
/** Handle controlling a running log stream. */
|
|
100
|
+
interface ContainerLogStreamHandle {
|
|
101
|
+
/** Stop polling and tear down every attached log stream. Idempotent. */
|
|
102
|
+
close: () => void;
|
|
103
|
+
}
|
|
104
|
+
/** The minimal structural slice of a `dockerode` log stream this module consumes. */
|
|
105
|
+
interface DockerLogStream {
|
|
106
|
+
destroy: () => void;
|
|
107
|
+
on: (event: "data" | "end" | "error", listener: (chunk?: Buffer) => void) => void;
|
|
108
|
+
}
|
|
109
|
+
/** The minimal structural slice of a `dockerode` instance this module consumes. */
|
|
110
|
+
interface DockerLike {
|
|
111
|
+
getContainer: (id: string) => {
|
|
112
|
+
logs: (options: {
|
|
113
|
+
follow: true;
|
|
114
|
+
stderr: true;
|
|
115
|
+
stdout: true;
|
|
116
|
+
tail: "all";
|
|
117
|
+
timestamps: false;
|
|
118
|
+
}) => Promise<DockerLogStream>;
|
|
119
|
+
};
|
|
120
|
+
listContainers: (options: {
|
|
121
|
+
filters: {
|
|
122
|
+
status: ["running"];
|
|
123
|
+
};
|
|
124
|
+
}) => Promise<{
|
|
125
|
+
Id: string;
|
|
126
|
+
Image: string;
|
|
127
|
+
}[]>;
|
|
128
|
+
modem: {
|
|
129
|
+
demuxStream: (stream: DockerLogStream, stdout: Writable, stderr: Writable) => void;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Follow the local Docker logs of every declared container, emitting each output
|
|
134
|
+
* line through `onLine` tagged with its export name. Polls for containers (they
|
|
135
|
+
* start lazily on first request and may be replaced on restart), attaches once
|
|
136
|
+
* per container id, and drops streams whose container has gone. Returns
|
|
137
|
+
* immediately with a `close()` handle; all work happens asynchronously.
|
|
138
|
+
*/
|
|
139
|
+
declare const streamContainerLogs: (options: ContainerLogStreamOptions) => ContainerLogStreamHandle;
|
|
68
140
|
/**
|
|
69
141
|
* The meta-frameworks Lunora can compose with, plus `"none"` for a standalone
|
|
70
142
|
* SPA / SSR-less project (the current default). Mirrors PLAN4 §2.4.
|
|
@@ -1234,4 +1306,4 @@ interface WranglerProjectValidationResult {
|
|
|
1234
1306
|
* `{ problems, wranglerPath }` shape plus the structured `report`.
|
|
1235
1307
|
*/
|
|
1236
1308
|
declare const validateWranglerProject: (options: WranglerProjectValidationOptions) => WranglerProjectValidationResult;
|
|
1237
|
-
export { ACCENT, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, classifyEdit, createConfirm, detectAgentRules, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, fillDevSecrets, findWranglerFile, formatLunoraEvent, generateSecretValue, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readLinkedProject, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, requiredSecrets, resolveRemoteEnabled, secretsForPackages, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeLinkedProject };
|
|
1309
|
+
export { ACCENT, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, classifyEdit, createConfirm, detectAgentRules, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, fillDevSecrets, findWranglerFile, formatLunoraEvent, generateSecretValue, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readLinkedProject, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, requiredSecrets, resolveRemoteEnabled, secretsForPackages, streamContainerLogs, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeLinkedProject };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ContainerIR, WorkflowIR, QueueIR } from '@lunora/codegen';
|
|
2
2
|
export type { ContainerIR, WorkflowIR } from '@lunora/codegen';
|
|
3
|
+
import { Writable } from 'node:stream';
|
|
3
4
|
import 'ts-morph';
|
|
4
5
|
export { type A as AdditivePolicyEdit, type D as DestructivePolicyEdit, type P as PolicyEdit, type a as PolicyScaffoldFailureReason, type b as ScaffoldFileResult, type S as ScaffoldPolicyEdit, type c as WireResult, type W as WireRlsEdit, d as classifyPolicyEdit, s as scaffoldPolicyFile, w as wireRlsIntoProcedure } from "./packem_shared/policy-scaffold.d-DCmwn7zQ.js";
|
|
5
6
|
/**
|
|
@@ -65,6 +66,77 @@ interface DiscoverContainerInfoResult {
|
|
|
65
66
|
* (inference).
|
|
66
67
|
*/
|
|
67
68
|
declare const discoverContainerInfo: (projectRoot: string, schemaDirectory: string) => DiscoverContainerInfoResult;
|
|
69
|
+
/** Severity a container output line is surfaced at: `stderr` → `error`, `stdout` → `info`. */
|
|
70
|
+
type ContainerLogLevel = "error" | "info";
|
|
71
|
+
/** One declared container to follow, identified by the names codegen lifts from `defineContainer`. */
|
|
72
|
+
interface ContainerLogSource {
|
|
73
|
+
/** Generated Durable Object class name, e.g. `TranscoderContainer`. Wrangler's dev image is `cloudflare-dev/<lowercased>`. */
|
|
74
|
+
className: string;
|
|
75
|
+
/** The `lunora/containers.ts` export name, e.g. `transcoder` — used as the display tag. */
|
|
76
|
+
exportName: string;
|
|
77
|
+
}
|
|
78
|
+
/** A single line of container output handed back to the caller. */
|
|
79
|
+
interface ContainerLogLine {
|
|
80
|
+
/** `"error"` for the container's stderr, `"info"` for its stdout. */
|
|
81
|
+
level: ContainerLogLevel;
|
|
82
|
+
/** The container's export name (`transcoder`), for tagging the line. */
|
|
83
|
+
name: string;
|
|
84
|
+
/** One output line, with the trailing newline (and any `\r`) stripped. */
|
|
85
|
+
text: string;
|
|
86
|
+
}
|
|
87
|
+
interface ContainerLogStreamOptions {
|
|
88
|
+
/** The declared containers to follow. An empty list yields an inert handle. */
|
|
89
|
+
containers: ReadonlyArray<ContainerLogSource>;
|
|
90
|
+
/** Injected Docker client — defaults to a real lazily-imported `dockerode` instance. Tests pass a stub. */
|
|
91
|
+
docker?: DockerLike;
|
|
92
|
+
/** Called once per container output line. */
|
|
93
|
+
onLine: (line: ContainerLogLine) => void;
|
|
94
|
+
/** Called once when the Docker engine can't be reached (re-armed after it recovers). Defaults to silent. */
|
|
95
|
+
onUnavailable?: (message: string) => void;
|
|
96
|
+
/** Poll interval override, in ms. */
|
|
97
|
+
pollIntervalMs?: number;
|
|
98
|
+
}
|
|
99
|
+
/** Handle controlling a running log stream. */
|
|
100
|
+
interface ContainerLogStreamHandle {
|
|
101
|
+
/** Stop polling and tear down every attached log stream. Idempotent. */
|
|
102
|
+
close: () => void;
|
|
103
|
+
}
|
|
104
|
+
/** The minimal structural slice of a `dockerode` log stream this module consumes. */
|
|
105
|
+
interface DockerLogStream {
|
|
106
|
+
destroy: () => void;
|
|
107
|
+
on: (event: "data" | "end" | "error", listener: (chunk?: Buffer) => void) => void;
|
|
108
|
+
}
|
|
109
|
+
/** The minimal structural slice of a `dockerode` instance this module consumes. */
|
|
110
|
+
interface DockerLike {
|
|
111
|
+
getContainer: (id: string) => {
|
|
112
|
+
logs: (options: {
|
|
113
|
+
follow: true;
|
|
114
|
+
stderr: true;
|
|
115
|
+
stdout: true;
|
|
116
|
+
tail: "all";
|
|
117
|
+
timestamps: false;
|
|
118
|
+
}) => Promise<DockerLogStream>;
|
|
119
|
+
};
|
|
120
|
+
listContainers: (options: {
|
|
121
|
+
filters: {
|
|
122
|
+
status: ["running"];
|
|
123
|
+
};
|
|
124
|
+
}) => Promise<{
|
|
125
|
+
Id: string;
|
|
126
|
+
Image: string;
|
|
127
|
+
}[]>;
|
|
128
|
+
modem: {
|
|
129
|
+
demuxStream: (stream: DockerLogStream, stdout: Writable, stderr: Writable) => void;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Follow the local Docker logs of every declared container, emitting each output
|
|
134
|
+
* line through `onLine` tagged with its export name. Polls for containers (they
|
|
135
|
+
* start lazily on first request and may be replaced on restart), attaches once
|
|
136
|
+
* per container id, and drops streams whose container has gone. Returns
|
|
137
|
+
* immediately with a `close()` handle; all work happens asynchronously.
|
|
138
|
+
*/
|
|
139
|
+
declare const streamContainerLogs: (options: ContainerLogStreamOptions) => ContainerLogStreamHandle;
|
|
68
140
|
/**
|
|
69
141
|
* The meta-frameworks Lunora can compose with, plus `"none"` for a standalone
|
|
70
142
|
* SPA / SSR-less project (the current default). Mirrors PLAN4 §2.4.
|
|
@@ -1234,4 +1306,4 @@ interface WranglerProjectValidationResult {
|
|
|
1234
1306
|
* `{ problems, wranglerPath }` shape plus the structured `report`.
|
|
1235
1307
|
*/
|
|
1236
1308
|
declare const validateWranglerProject: (options: WranglerProjectValidationOptions) => WranglerProjectValidationResult;
|
|
1237
|
-
export { ACCENT, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, classifyEdit, createConfirm, detectAgentRules, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, fillDevSecrets, findWranglerFile, formatLunoraEvent, generateSecretValue, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readLinkedProject, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, requiredSecrets, resolveRemoteEnabled, secretsForPackages, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeLinkedProject };
|
|
1309
|
+
export { ACCENT, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, classifyEdit, createConfirm, detectAgentRules, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, fillDevSecrets, findWranglerFile, formatLunoraEvent, generateSecretValue, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readLinkedProject, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, requiredSecrets, resolveRemoteEnabled, secretsForPackages, streamContainerLogs, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeLinkedProject };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, LUNORA_SKILL_NAMES, ROOT_SKILL_NAME, claimAgentRulesHint, detectAgentRules } from './packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs';
|
|
2
2
|
export { discoverContainerInfo } from './packem_shared/discoverContainerInfo-BXFs6Wav.mjs';
|
|
3
|
+
export { streamContainerLogs } from './packem_shared/streamContainerLogs-BZ4cOZwH.mjs';
|
|
3
4
|
export { detectFramework } from './packem_shared/detectFramework-Br-BcPBq.mjs';
|
|
4
5
|
export { DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, parseDevVariableEntries } from './packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs';
|
|
5
6
|
export { inferLunoraBindings, packageNamesFromBindings } from './packem_shared/inferLunoraBindings-b9SJwb2s.mjs';
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { Writable } from 'node:stream';
|
|
2
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
3
|
+
|
|
4
|
+
const DEV_CONTAINER_IMAGE_PREFIX = "cloudflare-dev/";
|
|
5
|
+
const DEFAULT_POLL_INTERVAL_MS = 1500;
|
|
6
|
+
const createDefaultDocker = async () => {
|
|
7
|
+
const { default: Dockerode } = await import('dockerode');
|
|
8
|
+
return new Dockerode();
|
|
9
|
+
};
|
|
10
|
+
const classFromImage = (image) => {
|
|
11
|
+
if (!image.startsWith(DEV_CONTAINER_IMAGE_PREFIX)) {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
const [segment] = image.slice(DEV_CONTAINER_IMAGE_PREFIX.length).split(":");
|
|
15
|
+
return segment !== void 0 && segment.length > 0 ? segment : void 0;
|
|
16
|
+
};
|
|
17
|
+
const lineBufferWritable = (emit) => {
|
|
18
|
+
const decoder = new StringDecoder("utf8");
|
|
19
|
+
let buffer = "";
|
|
20
|
+
const flushLine = (line) => {
|
|
21
|
+
emit(line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
22
|
+
};
|
|
23
|
+
return new Writable({
|
|
24
|
+
final(callback) {
|
|
25
|
+
buffer += decoder.end();
|
|
26
|
+
if (buffer.length > 0) {
|
|
27
|
+
flushLine(buffer);
|
|
28
|
+
buffer = "";
|
|
29
|
+
}
|
|
30
|
+
callback();
|
|
31
|
+
},
|
|
32
|
+
write(chunk, _encoding, callback) {
|
|
33
|
+
buffer += decoder.write(chunk);
|
|
34
|
+
const lines = buffer.split("\n");
|
|
35
|
+
buffer = lines.pop() ?? "";
|
|
36
|
+
for (const line of lines) {
|
|
37
|
+
flushLine(line);
|
|
38
|
+
}
|
|
39
|
+
callback();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const streamContainerLogs = (options) => {
|
|
44
|
+
const classToExport = new Map(options.containers.map((source) => [source.className.toLowerCase(), source.exportName]));
|
|
45
|
+
if (classToExport.size === 0) {
|
|
46
|
+
return { close: () => {
|
|
47
|
+
} };
|
|
48
|
+
}
|
|
49
|
+
const interval = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
50
|
+
const attached = /* @__PURE__ */ new Map();
|
|
51
|
+
let closed = false;
|
|
52
|
+
let unavailableNotified = false;
|
|
53
|
+
let timer;
|
|
54
|
+
let dockerPromise;
|
|
55
|
+
const getDocker = async () => {
|
|
56
|
+
dockerPromise ??= options.docker ? Promise.resolve(options.docker) : createDefaultDocker();
|
|
57
|
+
return dockerPromise;
|
|
58
|
+
};
|
|
59
|
+
const attach = async (docker, id, exportName) => {
|
|
60
|
+
try {
|
|
61
|
+
const stream = await docker.getContainer(id).logs({ follow: true, stderr: true, stdout: true, tail: "all", timestamps: false });
|
|
62
|
+
if (closed) {
|
|
63
|
+
stream.destroy();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const stdout = lineBufferWritable((text) => {
|
|
67
|
+
options.onLine({ level: "info", name: exportName, text });
|
|
68
|
+
});
|
|
69
|
+
const stderr = lineBufferWritable((text) => {
|
|
70
|
+
options.onLine({ level: "error", name: exportName, text });
|
|
71
|
+
});
|
|
72
|
+
docker.modem.demuxStream(stream, stdout, stderr);
|
|
73
|
+
stream.on("end", () => {
|
|
74
|
+
stdout.end();
|
|
75
|
+
stderr.end();
|
|
76
|
+
attached.delete(id);
|
|
77
|
+
});
|
|
78
|
+
stream.on("error", () => {
|
|
79
|
+
attached.delete(id);
|
|
80
|
+
});
|
|
81
|
+
attached.set(id, stream);
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const listRunning = async () => {
|
|
86
|
+
try {
|
|
87
|
+
const docker = await getDocker();
|
|
88
|
+
const running = await docker.listContainers({ filters: { status: ["running"] } });
|
|
89
|
+
unavailableNotified = false;
|
|
90
|
+
return running;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (!unavailableNotified) {
|
|
93
|
+
unavailableNotified = true;
|
|
94
|
+
options.onUnavailable?.(error instanceof Error ? error.message : String(error));
|
|
95
|
+
}
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const reconcile = async (docker, running) => {
|
|
100
|
+
const live = /* @__PURE__ */ new Set();
|
|
101
|
+
for (const summary of running) {
|
|
102
|
+
const className = classFromImage(summary.Image);
|
|
103
|
+
const exportName = className === void 0 ? void 0 : classToExport.get(className);
|
|
104
|
+
if (exportName === void 0) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
live.add(summary.Id);
|
|
108
|
+
if (!attached.has(summary.Id)) {
|
|
109
|
+
await attach(docker, summary.Id, exportName);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const [id, stream] of attached) {
|
|
113
|
+
if (!live.has(id)) {
|
|
114
|
+
stream.destroy();
|
|
115
|
+
attached.delete(id);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const poll = async () => {
|
|
120
|
+
if (closed) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const running = await listRunning();
|
|
124
|
+
if (running === void 0) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
await reconcile(await getDocker(), running);
|
|
128
|
+
};
|
|
129
|
+
let polling = false;
|
|
130
|
+
const onTick = () => {
|
|
131
|
+
if (polling || closed) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
polling = true;
|
|
135
|
+
poll().finally(() => {
|
|
136
|
+
polling = false;
|
|
137
|
+
}).catch(() => void 0);
|
|
138
|
+
};
|
|
139
|
+
timer = setInterval(onTick, interval);
|
|
140
|
+
timer.unref();
|
|
141
|
+
onTick();
|
|
142
|
+
return {
|
|
143
|
+
close: () => {
|
|
144
|
+
closed = true;
|
|
145
|
+
if (timer) {
|
|
146
|
+
clearInterval(timer);
|
|
147
|
+
timer = void 0;
|
|
148
|
+
}
|
|
149
|
+
for (const [id, stream] of attached) {
|
|
150
|
+
stream.destroy();
|
|
151
|
+
attached.delete(id);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export { streamContainerLogs };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/config",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.19",
|
|
4
4
|
"description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bindings",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@lunora/container": "1.0.0-alpha.4",
|
|
55
55
|
"@lunora/seed": "1.0.0-alpha.5",
|
|
56
56
|
"@visulima/colorize": "2.0.0-alpha.14",
|
|
57
|
+
"dockerode": "^4.0.12",
|
|
57
58
|
"es-module-lexer": "^2.1.0",
|
|
58
59
|
"jsonc-parser": "^3.3.1",
|
|
59
60
|
"ts-morph": "^28.0.0"
|