@elementumai/edk 0.9.11 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -5
- package/dist-sdk/src/catalog/factories.d.ts +35 -14
- package/dist-sdk/src/catalog/factories.js +64 -13
- package/dist-sdk/src/catalog/from-authoring.js +4 -4
- package/dist-sdk/src/catalog/index.d.ts +1 -1
- package/dist-sdk/src/catalog/org.js +3 -2
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/catalog/types.d.ts +13 -3
- package/dist-sdk/src/core/triggers/on-demand.d.ts +4 -28
- package/dist-sdk/src/core/triggers/on-demand.js +2 -4
- package/dist-sdk/src/engine/entity.d.ts +2 -0
- package/dist-sdk/src/engine/logging.d.ts +90 -0
- package/dist-sdk/src/engine/logging.js +124 -0
- package/dist-sdk/src/engine/progress.d.ts +119 -0
- package/dist-sdk/src/engine/progress.js +647 -0
- package/dist-sdk/src/engine/pull/result-output.d.ts +24 -0
- package/dist-sdk/src/engine/pull/result-output.js +48 -0
- package/dist-sdk/src/entities/agent/tools.d.ts +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +8 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -4
- package/dist-sdk/src/entities/app/to-tf.js +9 -13
- package/dist-sdk/src/entities/automation/build.d.ts +11 -16
- package/dist-sdk/src/entities/automation/build.js +38 -8
- package/dist-sdk/src/entities/automation/catalog-render.js +1 -1
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +1 -2
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +23 -5
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +239 -34
- package/dist-sdk/src/entities/automation/from-tf.js +168 -23
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/module.js +2 -2
- package/dist-sdk/src/entities/automation/output-field-types.js +25 -13
- package/dist-sdk/src/entities/automation/script-code.d.ts +12 -4
- package/dist-sdk/src/entities/automation/script-code.js +659 -101
- package/dist-sdk/src/entities/automation/tasks.d.ts +60 -28
- package/dist-sdk/src/entities/automation/tasks.js +31 -15
- package/dist-sdk/src/entities/automation/to-tf.js +362 -58
- package/dist-sdk/src/entities/automation/triggers.d.ts +15 -9
- package/dist-sdk/src/entities/automation/triggers.js +4 -2
- package/dist-sdk/src/entities/chart/build.d.ts +15 -3
- package/dist-sdk/src/entities/chart/build.js +6 -1
- package/dist-sdk/src/entities/chart/from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/chart/from-tf.js +71 -8
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/index.js +1 -1
- package/dist-sdk/src/entities/chart/printer.js +27 -7
- package/dist-sdk/src/entities/chart/to-tf.js +56 -2
- package/dist-sdk/src/entities/datamine/from-tf.js +11 -1
- package/dist-sdk/src/entities/element/build.d.ts +6 -5
- package/dist-sdk/src/entities/element/from-tf.js +3 -2
- package/dist-sdk/src/entities/element/module.js +1 -0
- package/dist-sdk/src/entities/element/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/element/to-tf.js +9 -1
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +73 -1
- package/dist-sdk/src/entities/field/metadata.d.ts +18 -0
- package/dist-sdk/src/entities/field/metadata.js +34 -0
- package/dist-sdk/src/entities/relationship/build.d.ts +17 -6
- package/dist-sdk/src/entities/relationship/column-contract.d.ts +24 -0
- package/dist-sdk/src/entities/relationship/column-contract.js +41 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +19 -34
- package/dist-sdk/src/entities/relationship/to-tf.js +15 -2
- package/dist-sdk/src/entities/shared/context.d.ts +6 -3
- package/dist-sdk/src/entities/shared/context.js +19 -1
- package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
- package/dist-sdk/src/entities/shared/filters/index.js +28 -0
- package/dist-sdk/src/entities/shared/filters/print.js +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +8 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +10 -6
- package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -23
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +17 -0
- package/dist-sdk/src/entities/skill/tools.d.ts +38 -12
- package/dist-sdk/src/entities/skill/tools.js +2 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +8 -12
- package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -44
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +45 -7
- package/dist-sdk/src/entities/table/build.js +10 -2
- package/dist-sdk/src/entities/view/to-tf.js +5 -7
- package/dist-sdk/src/entities/widget/build.d.ts +26 -0
- package/dist-sdk/src/entities/widget/from-tf.js +30 -5
- package/dist-sdk/src/entities/widget/to-tf.js +111 -7
- package/dist-sdk/src/graph/types.d.ts +5 -0
- package/package.json +1 -1
- package/dist-sdk/src/core/types/platform.d.ts +0 -2
- package/dist-sdk/src/core/types/platform.js +0 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime-neutral structured logging contract shared by the TypeScript CLI,
|
|
3
|
+
* ei, and the provider. Renderers and verbosity policy deliberately live
|
|
4
|
+
* elsewhere; this module only defines the event shape.
|
|
5
|
+
*/
|
|
6
|
+
export const LOG_LEVELS = ["DEBUG", "INFO", "WARN", "ERROR"];
|
|
7
|
+
export const LOG_COMPONENTS = ["edk", "ei", "provider", "tofu"];
|
|
8
|
+
/** Diagnostic rendering defaults to structured plaintext; JSON is explicit. */
|
|
9
|
+
export const LOG_FORMATS = ["text", "json"];
|
|
10
|
+
export function parseProgressEvent(line) {
|
|
11
|
+
try {
|
|
12
|
+
const value = JSON.parse(line);
|
|
13
|
+
if (typeof value !== "object" || value === null)
|
|
14
|
+
return undefined;
|
|
15
|
+
const event = value;
|
|
16
|
+
if (event.protocol_version !== 1 || typeof event.sequence !== "number" ||
|
|
17
|
+
typeof event.timestamp !== "string" || typeof event.event !== "string" || !event.event.startsWith("progress_") ||
|
|
18
|
+
typeof event.operation !== "string" || typeof event.phase !== "string")
|
|
19
|
+
return undefined;
|
|
20
|
+
if ((event.event === "progress_enter" || event.event === "progress_update") && typeof event.label !== "string")
|
|
21
|
+
return undefined;
|
|
22
|
+
if (event.current !== undefined && (typeof event.current !== "number" || event.current < 0))
|
|
23
|
+
return undefined;
|
|
24
|
+
if (event.total !== undefined && (typeof event.total !== "number" || event.total < 0))
|
|
25
|
+
return undefined;
|
|
26
|
+
if (event.current !== undefined && event.total !== undefined && event.current > event.total)
|
|
27
|
+
return undefined;
|
|
28
|
+
if (event.text_effects !== undefined && !isTextEffects(event.text_effects))
|
|
29
|
+
return undefined;
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function isEventStyle(value) {
|
|
37
|
+
if (typeof value !== "object" || value === null)
|
|
38
|
+
return false;
|
|
39
|
+
const style = value;
|
|
40
|
+
return (style.color === undefined || typeof style.color === "string") &&
|
|
41
|
+
["bold", "italic", "underline", "dim", "strikethrough", "inverse", "blink", "rapid_blink", "hidden", "overline", "double_underline", "framed", "encircled"].every((key) => style[key] === undefined || typeof style[key] === "boolean");
|
|
42
|
+
}
|
|
43
|
+
function isTextEffects(value) {
|
|
44
|
+
if (!Array.isArray(value))
|
|
45
|
+
return false;
|
|
46
|
+
let previousStart = -1;
|
|
47
|
+
for (const item of value) {
|
|
48
|
+
if (!isEventStyle(item))
|
|
49
|
+
return false;
|
|
50
|
+
const effect = item;
|
|
51
|
+
if (!Number.isInteger(effect.start) || !Number.isInteger(effect.end) ||
|
|
52
|
+
effect.start < 0 || effect.end <= effect.start ||
|
|
53
|
+
effect.start < previousStart)
|
|
54
|
+
return false;
|
|
55
|
+
previousStart = effect.start;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
export function parseBridgeLogEvent(line) {
|
|
60
|
+
try {
|
|
61
|
+
const value = JSON.parse(line);
|
|
62
|
+
if (typeof value !== "object" || value === null)
|
|
63
|
+
return undefined;
|
|
64
|
+
const event = value;
|
|
65
|
+
if (event.protocol_version !== 1 || typeof event.sequence !== "number" || typeof event.timestamp !== "string" || event.event !== "log" ||
|
|
66
|
+
typeof event.level !== "string" || typeof event.component !== "string" ||
|
|
67
|
+
typeof event.message !== "string")
|
|
68
|
+
return undefined;
|
|
69
|
+
if (!["DEBUG", "INFO", "WARN", "ERROR"].includes(event.level))
|
|
70
|
+
return undefined;
|
|
71
|
+
if (event.text_effects !== undefined && !isTextEffects(event.text_effects))
|
|
72
|
+
return undefined;
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const RESERVED = new Set(["timestamp", "level", "component", "message"]);
|
|
80
|
+
/** Convert common JS camelCase keys to the contract's flat snake_case keys. */
|
|
81
|
+
export function snakeCaseKey(key) {
|
|
82
|
+
return key
|
|
83
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
84
|
+
.replace(/[-\s]+/g, "_")
|
|
85
|
+
.toLowerCase();
|
|
86
|
+
}
|
|
87
|
+
function errorFields(error) {
|
|
88
|
+
return {
|
|
89
|
+
error: error.message,
|
|
90
|
+
error_type: error.name || "Error",
|
|
91
|
+
...(error.stack === undefined ? {} : { stack_trace: error.stack }),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function createLogEvent(input) {
|
|
95
|
+
const event = {
|
|
96
|
+
timestamp: input.timestamp ?? new Date().toISOString(),
|
|
97
|
+
level: input.level,
|
|
98
|
+
component: input.component,
|
|
99
|
+
message: input.message,
|
|
100
|
+
};
|
|
101
|
+
for (const [key, value] of Object.entries(input)) {
|
|
102
|
+
if (RESERVED.has(key) || value === undefined)
|
|
103
|
+
continue;
|
|
104
|
+
const normalized = snakeCaseKey(key);
|
|
105
|
+
if (RESERVED.has(normalized))
|
|
106
|
+
continue;
|
|
107
|
+
if (value instanceof Error)
|
|
108
|
+
Object.assign(event, errorFields(value));
|
|
109
|
+
else
|
|
110
|
+
event[normalized] = value;
|
|
111
|
+
}
|
|
112
|
+
return event;
|
|
113
|
+
}
|
|
114
|
+
/** Serialize exactly one complete JSON event, suitable for NDJSON output. */
|
|
115
|
+
export function serializeLogEvent(event) {
|
|
116
|
+
return `${JSON.stringify(event)}\n`;
|
|
117
|
+
}
|
|
118
|
+
export function createLogWriter(destination = process.stderr) {
|
|
119
|
+
return {
|
|
120
|
+
emit(input) {
|
|
121
|
+
destination.write(serializeLogEvent(createLogEvent(input)));
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { LogLevel, ProgressEvent, TextEffect } from "./logging.js";
|
|
2
|
+
import type { PullResultSegment } from "./pull/result-output.js";
|
|
3
|
+
/**
|
|
4
|
+
* Where human-facing progress goes.
|
|
5
|
+
*
|
|
6
|
+
* Commands like `elementum pull app` reserve stdout for a single JSON summary,
|
|
7
|
+
* so every status line historically went to stderr. Terminals routinely color
|
|
8
|
+
* the entire stderr stream red, which made a normal interactive pull read as a
|
|
9
|
+
* wall of errors.
|
|
10
|
+
*
|
|
11
|
+
* Technical progress belongs to stderr unconditionally. This keeps stdout
|
|
12
|
+
* available for user data and messages, including when EDK is itself piped.
|
|
13
|
+
*
|
|
14
|
+
* Diagnostics are NOT progress. Warnings and errors stay on stderr
|
|
15
|
+
* unconditionally, because there the red is the point.
|
|
16
|
+
*/
|
|
17
|
+
/** The stream human-facing progress should be written to right now. */
|
|
18
|
+
export declare function progressStream(): NodeJS.WriteStream;
|
|
19
|
+
/** Configure the global machine-readable diagnostic mode. */
|
|
20
|
+
export declare function configureMachineReadableLogs(enabled: boolean): void;
|
|
21
|
+
export declare function machineReadableLogsEnabled(): boolean;
|
|
22
|
+
/** Write one newline-terminated progress line to {@link progressStream}. */
|
|
23
|
+
export declare function writeProgress(line: string, textEffects?: readonly TextEffect[]): void;
|
|
24
|
+
/** Render one EDK-owned technical log through the same live-output arbiter. */
|
|
25
|
+
export declare function writeTechnicalLog(level: LogLevel, source: string, message: string, timestamp?: string, messageEffects?: readonly TextEffect[]): void;
|
|
26
|
+
/** Write user-owned output without allowing it to collide with the live row. */
|
|
27
|
+
export declare function writeUserOutput(text: string, destination?: NodeJS.WritableStream): void;
|
|
28
|
+
/** Write a final user-facing operation status without contaminating pipes. */
|
|
29
|
+
export declare function writeUserStatus(message: string, color: "green" | "red" | "yellow"): void;
|
|
30
|
+
export interface LiveProgressOptions {
|
|
31
|
+
readonly label: string;
|
|
32
|
+
/** Omit when the number of steps is not knowable in advance. */
|
|
33
|
+
readonly total?: number;
|
|
34
|
+
readonly intervalMs?: number;
|
|
35
|
+
/** Optional stable upper bound for the status label, excluding progress suffixes. */
|
|
36
|
+
readonly maxLabelLength?: number;
|
|
37
|
+
/** Preserve the current counter when a label-only update changes phase. */
|
|
38
|
+
readonly retainCountOnLabelChange?: boolean;
|
|
39
|
+
/** Keep label changes as durable lines; useful for pull stage history. */
|
|
40
|
+
readonly persistLabelChanges?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A single, terminal-aware status line. It is always rendered at the current
|
|
44
|
+
* cursor position, immediately after the durable output already displayed;
|
|
45
|
+
* output arriving from logs or child processes first clears and then redraws
|
|
46
|
+
* that row. Non-TTY streams deliberately render nothing.
|
|
47
|
+
*/
|
|
48
|
+
export declare class LiveProgress {
|
|
49
|
+
private readonly stream;
|
|
50
|
+
private total?;
|
|
51
|
+
private readonly intervalMs;
|
|
52
|
+
private readonly maxLabelLength?;
|
|
53
|
+
private readonly retainCountOnLabelChange;
|
|
54
|
+
private readonly persistLabelChanges;
|
|
55
|
+
private label;
|
|
56
|
+
private value;
|
|
57
|
+
private frame;
|
|
58
|
+
private startedAt;
|
|
59
|
+
private timer;
|
|
60
|
+
private running;
|
|
61
|
+
private suspended;
|
|
62
|
+
private textEffects;
|
|
63
|
+
private bridgeSection;
|
|
64
|
+
private writing;
|
|
65
|
+
private batchDepth;
|
|
66
|
+
private outputQueue;
|
|
67
|
+
private readonly handleTerminationSignal;
|
|
68
|
+
constructor(options: LiveProgressOptions);
|
|
69
|
+
get tty(): boolean;
|
|
70
|
+
start(): this;
|
|
71
|
+
update(label: string): void;
|
|
72
|
+
setState(state: {
|
|
73
|
+
readonly label?: string;
|
|
74
|
+
readonly current?: number;
|
|
75
|
+
readonly total?: number;
|
|
76
|
+
readonly textEffects?: readonly TextEffect[];
|
|
77
|
+
}): void;
|
|
78
|
+
/** Temporarily let an EI-owned section replace the command-owned status. */
|
|
79
|
+
enterBridgeSection(event: ProgressEvent): void;
|
|
80
|
+
/** Finish only EI's section; the pull command still owns the live renderer. */
|
|
81
|
+
leaveBridgeSection(sectionId: string | undefined): void;
|
|
82
|
+
private finalizeLabel;
|
|
83
|
+
increment(amount?: number): void;
|
|
84
|
+
/** Temporarily return terminal ownership to an interactive child process. */
|
|
85
|
+
suspend(): void;
|
|
86
|
+
resume(): void;
|
|
87
|
+
stop(): void;
|
|
88
|
+
/** Write a durable log line above the status row. */
|
|
89
|
+
writeLog(line: string, textEffects?: readonly TextEffect[]): void;
|
|
90
|
+
writeUserOutput(text: string, destination?: NodeJS.WritableStream): void;
|
|
91
|
+
private configureTerminal;
|
|
92
|
+
private restoreTerminal;
|
|
93
|
+
private clearStatus;
|
|
94
|
+
private attachTerminationHandlers;
|
|
95
|
+
private detachTerminationHandlers;
|
|
96
|
+
private render;
|
|
97
|
+
private currentStatusRendered;
|
|
98
|
+
private bar;
|
|
99
|
+
/** Single terminal writer. Priority 0 is protocol/log output; priority 1 is animation. */
|
|
100
|
+
private enqueue;
|
|
101
|
+
beginBatch(): void;
|
|
102
|
+
endBatch(): void;
|
|
103
|
+
private flushQueue;
|
|
104
|
+
}
|
|
105
|
+
/** Coalesce all live-progress writes caused by one child-stream drain. */
|
|
106
|
+
export declare function withProgressBatch<T>(fn: () => T): T;
|
|
107
|
+
/** Current live renderer, used by subprocess wrappers to protect TTY UI. */
|
|
108
|
+
export declare function suspendProgress(): void;
|
|
109
|
+
export declare function resumeProgress(): void;
|
|
110
|
+
export declare function updateProgress(label: string): void;
|
|
111
|
+
export declare function incrementProgress(amount?: number): void;
|
|
112
|
+
export declare function setProgressCount(label: string, current: number, total: number): void;
|
|
113
|
+
export declare function liveProgressActive(): boolean;
|
|
114
|
+
/** Apply a bridge lifecycle event without allowing the producer to write to the terminal. */
|
|
115
|
+
export declare function applyProgressEvent(event: ProgressEvent): void;
|
|
116
|
+
export declare function renderTextEffects(text: string, effects: readonly TextEffect[] | undefined): string;
|
|
117
|
+
export declare function green(text: string): PullResultSegment;
|
|
118
|
+
export declare function red(text: string): PullResultSegment;
|
|
119
|
+
export declare function bold(text: string): PullResultSegment;
|