@m4trix/core 0.10.0 → 0.11.0
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.cjs +154 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +152 -1
- package/dist/index.js.map +1 -1
- package/dist/matrix/index.cjs +154 -0
- package/dist/matrix/index.cjs.map +1 -1
- package/dist/matrix/index.d.ts +72 -1
- package/dist/matrix/index.js +152 -1
- package/dist/matrix/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1824,6 +1824,157 @@ var AgentFactory = class _AgentFactory {
|
|
|
1824
1824
|
);
|
|
1825
1825
|
}
|
|
1826
1826
|
};
|
|
1827
|
+
var CAMEL_CASE_REGEX = /^[a-z][a-zA-Z0-9]*$/;
|
|
1828
|
+
var LayerName = effect.Brand.refined(
|
|
1829
|
+
(s) => typeof s === "string" && CAMEL_CASE_REGEX.test(s),
|
|
1830
|
+
(s) => effect.Brand.error(`Expected camelCase (e.g. myLayerFoo), got: ${s}`)
|
|
1831
|
+
);
|
|
1832
|
+
var SkillDependency = {
|
|
1833
|
+
of(config) {
|
|
1834
|
+
const name = LayerName(config.name);
|
|
1835
|
+
const decode = effect.Schema.decodeUnknown(config.shape);
|
|
1836
|
+
return {
|
|
1837
|
+
_tag: "SkillDependencyDef",
|
|
1838
|
+
name,
|
|
1839
|
+
_name: config.name,
|
|
1840
|
+
shape: config.shape,
|
|
1841
|
+
decode
|
|
1842
|
+
};
|
|
1843
|
+
}
|
|
1844
|
+
};
|
|
1845
|
+
function toLayerArray(layers) {
|
|
1846
|
+
if (layers.length === 1 && Array.isArray(layers[0])) {
|
|
1847
|
+
return layers[0];
|
|
1848
|
+
}
|
|
1849
|
+
return [...layers];
|
|
1850
|
+
}
|
|
1851
|
+
function assertUniqueLayerNames(layers) {
|
|
1852
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1853
|
+
for (const dep of layers) {
|
|
1854
|
+
const key = dep.name;
|
|
1855
|
+
if (seen.has(key)) {
|
|
1856
|
+
throw new Error(`Duplicate layer name: ${key}`);
|
|
1857
|
+
}
|
|
1858
|
+
seen.add(key);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
var Skill = class _Skill {
|
|
1862
|
+
constructor(params) {
|
|
1863
|
+
this._inputSchema = params.inputSchema;
|
|
1864
|
+
this._chunkSchema = params.chunkSchema;
|
|
1865
|
+
this._doneSchema = params.doneSchema;
|
|
1866
|
+
this._layers = params.layers;
|
|
1867
|
+
this._defineFn = params.defineFn;
|
|
1868
|
+
}
|
|
1869
|
+
getState() {
|
|
1870
|
+
return {
|
|
1871
|
+
inputSchema: this._inputSchema,
|
|
1872
|
+
chunkSchema: this._chunkSchema,
|
|
1873
|
+
doneSchema: this._doneSchema,
|
|
1874
|
+
layers: this._layers,
|
|
1875
|
+
defineFn: this._defineFn
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
static of(_options) {
|
|
1879
|
+
return new _Skill({
|
|
1880
|
+
layers: []
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
input(schema) {
|
|
1884
|
+
return new _Skill({
|
|
1885
|
+
...this.getState(),
|
|
1886
|
+
inputSchema: schema
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
chunk(schema) {
|
|
1890
|
+
return new _Skill({
|
|
1891
|
+
...this.getState(),
|
|
1892
|
+
chunkSchema: schema
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
done(schema) {
|
|
1896
|
+
return new _Skill({
|
|
1897
|
+
...this.getState(),
|
|
1898
|
+
doneSchema: schema
|
|
1899
|
+
});
|
|
1900
|
+
}
|
|
1901
|
+
use(...layers) {
|
|
1902
|
+
const normalized = toLayerArray(layers);
|
|
1903
|
+
const allLayers = [...this._layers, ...normalized];
|
|
1904
|
+
assertUniqueLayerNames(allLayers);
|
|
1905
|
+
return new _Skill({
|
|
1906
|
+
...this.getState(),
|
|
1907
|
+
layers: allLayers
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1910
|
+
define(fn) {
|
|
1911
|
+
const state = this.getState();
|
|
1912
|
+
const inputSchema = state.inputSchema;
|
|
1913
|
+
const chunkSchema = state.chunkSchema;
|
|
1914
|
+
const doneSchema = state.doneSchema;
|
|
1915
|
+
const defineFn = fn;
|
|
1916
|
+
if (!inputSchema || !chunkSchema || !doneSchema || !defineFn) {
|
|
1917
|
+
throw new Error(
|
|
1918
|
+
"Skill.define requires input(), chunk(), and done() to be called before define()"
|
|
1919
|
+
);
|
|
1920
|
+
}
|
|
1921
|
+
const decodeInput = effect.Schema.decodeUnknown(inputSchema);
|
|
1922
|
+
const decodeChunk = effect.Schema.decodeUnknown(chunkSchema);
|
|
1923
|
+
const decodeDone = effect.Schema.decodeUnknown(doneSchema);
|
|
1924
|
+
const runDefine = async (input, runtime) => {
|
|
1925
|
+
const layersObj = runtime?.layers ?? {};
|
|
1926
|
+
const chunks = [];
|
|
1927
|
+
const emit = (chunk) => {
|
|
1928
|
+
const decoded = effect.Effect.runSync(
|
|
1929
|
+
decodeChunk(chunk)
|
|
1930
|
+
);
|
|
1931
|
+
chunks.push(decoded);
|
|
1932
|
+
};
|
|
1933
|
+
const done = await defineFn({
|
|
1934
|
+
input,
|
|
1935
|
+
emit,
|
|
1936
|
+
layers: layersObj
|
|
1937
|
+
});
|
|
1938
|
+
const decodedDone = effect.Effect.runSync(
|
|
1939
|
+
decodeDone(done)
|
|
1940
|
+
);
|
|
1941
|
+
return { chunks, done: decodedDone };
|
|
1942
|
+
};
|
|
1943
|
+
return {
|
|
1944
|
+
invokeStream: async function* (input, runtime) {
|
|
1945
|
+
const decodedInput = effect.Effect.runSync(
|
|
1946
|
+
decodeInput(input)
|
|
1947
|
+
);
|
|
1948
|
+
const layersObj = runtime?.layers ?? {};
|
|
1949
|
+
const chunks = [];
|
|
1950
|
+
const emit = (chunk) => {
|
|
1951
|
+
const decoded = effect.Effect.runSync(
|
|
1952
|
+
decodeChunk(chunk)
|
|
1953
|
+
);
|
|
1954
|
+
chunks.push(decoded);
|
|
1955
|
+
};
|
|
1956
|
+
const done = await defineFn({
|
|
1957
|
+
input: decodedInput,
|
|
1958
|
+
emit,
|
|
1959
|
+
layers: layersObj
|
|
1960
|
+
});
|
|
1961
|
+
const decodedDone = effect.Effect.runSync(
|
|
1962
|
+
decodeDone(done)
|
|
1963
|
+
);
|
|
1964
|
+
for (const c of chunks) {
|
|
1965
|
+
yield c;
|
|
1966
|
+
}
|
|
1967
|
+
yield { _tag: "Done", done: decodedDone };
|
|
1968
|
+
},
|
|
1969
|
+
invoke: async (input, runtime) => {
|
|
1970
|
+
const decodedInput = effect.Effect.runSync(
|
|
1971
|
+
decodeInput(input)
|
|
1972
|
+
);
|
|
1973
|
+
return runDefine(decodedInput, runtime);
|
|
1974
|
+
}
|
|
1975
|
+
};
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1827
1978
|
|
|
1828
1979
|
// src/matrix/io/protocols/sse.ts
|
|
1829
1980
|
function formatSSE(envelope) {
|
|
@@ -2048,9 +2199,12 @@ exports.ConfiguredChannel = ConfiguredChannel;
|
|
|
2048
2199
|
exports.EventMetaSchema = EventMetaSchema;
|
|
2049
2200
|
exports.ExposeAuthError = ExposeAuthError;
|
|
2050
2201
|
exports.ExpressEndpoint = ExpressEndpoint;
|
|
2202
|
+
exports.LayerName = LayerName;
|
|
2051
2203
|
exports.NextEndpoint = NextEndpoint;
|
|
2052
2204
|
exports.Pump = Pump;
|
|
2053
2205
|
exports.Sink = Sink;
|
|
2206
|
+
exports.Skill = Skill;
|
|
2207
|
+
exports.SkillDependency = SkillDependency;
|
|
2054
2208
|
exports.SocketIoFactory = SocketIoFactory;
|
|
2055
2209
|
exports.TransformMessages = TransformMessages;
|
|
2056
2210
|
exports.consoleTracer = consoleTracer;
|