@deepseek-ai/dsh-tmux-context 0.2.1-alpha.1 → 0.2.1-alpha.3

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.
Files changed (2) hide show
  1. package/lib/index.js +85 -33
  2. package/package.json +16 -16
package/lib/index.js CHANGED
@@ -53,7 +53,7 @@ const REMOTE_METHOD_DESCRIPTOR = "@deepseek-ai/dsh-typert-protocol/remote-method
53
53
  * a Host composition to read it.
54
54
  * @param service - owning Service instance, normally `this`.
55
55
  * @param serviceKey - exact Cordis service key.
56
- * @param options - optional distinct wire namespace.
56
+ * @param options - optional wire namespace.
57
57
  * @returns a frozen, inspectable binding with no compiler-injected metadata.
58
58
  */
59
59
  function bindTypertRemote(service, serviceKey, options = {}) {
@@ -61,7 +61,7 @@ function bindTypertRemote(service, serviceKey, options = {}) {
61
61
  const namespace = options.namespace ?? serviceKey;
62
62
  validateName("namespace", namespace);
63
63
  const ctx = Reflect.get(service, "ctx");
64
- if (ctx instanceof Context) provideInvocationAccessor(ctx);
64
+ if (Context.is(ctx)) provideInvocationAccessor(ctx);
65
65
  return Object.freeze({
66
66
  service,
67
67
  serviceKey,
@@ -76,7 +76,7 @@ var TypertRemoteService = class extends Service {
76
76
  * Register the Service and bind the same key to Typert Gateway.
77
77
  * @param ctx - owning Cordis Context.
78
78
  * @param serviceKey - exact Cordis service key and default wire namespace.
79
- * @param options - optional distinct wire namespace.
79
+ * @param options - optional wire namespace.
80
80
  */
81
81
  constructor(ctx, serviceKey, options = {}) {
82
82
  super(ctx, serviceKey);
@@ -96,21 +96,42 @@ function provideInvocationAccessor(ctx) {
96
96
  function Remote(methodExportOrOptions, context) {
97
97
  if (typeof methodExportOrOptions === "string") {
98
98
  validateName("Remote export name", methodExportOrOptions);
99
- return remoteDecorator({ kind: "direct" }, void 0, methodExportOrOptions);
100
- }
101
- if (typeof methodExportOrOptions === "object") {
102
- if (remoteOptionMode(methodExportOrOptions) !== "stream" || Reflect.ownKeys(methodExportOrOptions).length !== 1) throw new TypeError("typert-protocol: Remote options must contain exactly mode: \"stream\"");
103
- return remoteDecorator({ kind: "direct" }, "stream");
99
+ return remoteDecorator({ kind: "direct" }, { exportName: methodExportOrOptions });
104
100
  }
101
+ if (typeof methodExportOrOptions === "object") return remoteDecorator({ kind: "direct" }, markerOptions(methodExportOrOptions, REMOTE_OPTION_KEYS, "Remote options require name, mode: \"stream\", or resources"));
105
102
  if (context === void 0) throw new TypeError("typert-protocol: Remote decorator context is missing");
106
103
  addMarkerInitializer(context, { kind: "direct" });
107
104
  }
108
- function remoteOptionMode(options) {
109
- return Reflect.get(options, "mode");
105
+ const REMOTE_OPTION_KEYS = new Set([
106
+ "name",
107
+ "mode",
108
+ "resources"
109
+ ]);
110
+ /** Validate one decorator options object against its accepted keys and select the marker fields. */
111
+ function markerOptions(options, accepted, requirement) {
112
+ const keys = Reflect.ownKeys(options);
113
+ if (keys.length === 0 || keys.some((key) => typeof key !== "string" || !accepted.has(key)) || Object.hasOwn(options, "mode") && options.mode !== "stream") throw new TypeError(`typert-protocol: ${requirement}`);
114
+ const { mode, name, resources } = options;
115
+ if (name !== void 0) validateName("Remote export name", name);
116
+ return {
117
+ ...mode === void 0 ? {} : { mode },
118
+ ...name === void 0 ? {} : { exportName: name },
119
+ ...resources === void 0 ? {} : { resources: resourceReaders(resources) }
120
+ };
121
+ }
122
+ /** Freeze declared readers into the marker record; a misdeclared reader fails at decoration. */
123
+ function resourceReaders(resources) {
124
+ const readers = {};
125
+ for (const [kind, reader] of Object.entries(resources)) {
126
+ if (typeof reader !== "function") throw new TypeError(`typert-protocol: Remote resource reader "${kind}" must be a function`);
127
+ readers[kind] = reader;
128
+ }
129
+ if (Object.keys(readers).length === 0) throw new TypeError("typert-protocol: Remote resources require at least one reader");
130
+ return Object.freeze(readers);
110
131
  }
111
- function remoteDecorator(invocation, mode, exportName) {
132
+ function remoteDecorator(invocation, options = {}) {
112
133
  return function(_method, context) {
113
- addMarkerInitializer(context, invocation, mode, exportName);
134
+ addMarkerInitializer(context, invocation, options);
114
135
  };
115
136
  }
116
137
  function readRemoteMethodDescriptor(prototype) {
@@ -124,26 +145,27 @@ function readRemoteMethodDescriptor(prototype) {
124
145
  if (!Array.isArray(methods)) throw new TypeError("typert-protocol: Remote method descriptor methods must be an array");
125
146
  return descriptor;
126
147
  }
127
- function addMarkerInitializer(context, invocation, mode, exportName) {
148
+ function addMarkerInitializer(context, invocation, options = {}) {
128
149
  if (context.private || context.static || typeof context.name !== "string") throw new TypeError("typert-protocol: Remote decorators require a public instance method with a string name");
129
150
  const method = context.name;
130
151
  context.addInitializer(function() {
131
152
  const prototype = Object.getPrototypeOf(this);
132
153
  if (prototype === null) throw new TypeError(`typert-protocol: cannot mark Remote method "${method}" on an object without a prototype`);
133
- mark(prototype, method, invocation, mode, exportName);
154
+ mark(prototype, method, invocation, options);
134
155
  });
135
156
  }
136
- function mark(prototype, method, invocation, mode, exportName) {
157
+ function mark(prototype, method, invocation, { mode, exportName, resources }) {
137
158
  const descriptor = readRemoteMethodDescriptor(prototype);
138
159
  const marker = Object.freeze({
139
160
  method,
140
161
  ...exportName === void 0 || exportName === method ? {} : { exportName },
141
162
  ...mode === void 0 ? {} : { mode },
142
- invocation: Object.freeze(invocation)
163
+ invocation: Object.freeze(invocation),
164
+ ...resources === void 0 ? {} : { resources }
143
165
  });
144
166
  const current = descriptor?.methods.find((candidate) => candidate.method === method);
145
167
  if (current !== void 0) {
146
- if (current.exportName === marker.exportName && current.mode === marker.mode && sameInvocation(current.invocation, invocation)) return;
168
+ if (current.exportName === marker.exportName && current.mode === marker.mode && current.resources === marker.resources && sameInvocation(current.invocation, invocation)) return;
147
169
  throw new Error(`typert-protocol: Remote method "${method}" has conflicting invocation markers`);
148
170
  }
149
171
  Object.defineProperty(prototype, REMOTE_METHOD_DESCRIPTOR, {
@@ -1591,10 +1613,7 @@ var LlmError = class extends HarnessError {
1591
1613
  if (entry.provider.length === 0 || entry.displayName.length === 0 || entry.settingsNs.length === 0) throw new LlmError("configurable providers need a non-empty provider, displayName, and settingsNs", "INVALID_DIRECTORY");
1592
1614
  if (entry.settingsPath.some((segment) => segment.length === 0)) throw new LlmError(`configurable provider "${entry.provider}" has an empty settingsPath segment`, "INVALID_DIRECTORY");
1593
1615
  if (this.directory.has(entry.provider) && !own.has(entry.provider) || detached.some((seen) => seen.provider === entry.provider)) throw new LlmError(`configurable provider "${entry.provider}" is already declared`, "DUPLICATE_DIRECTORY");
1594
- detached.push({
1595
- ...entry,
1596
- settingsPath: [...entry.settingsPath]
1597
- });
1616
+ detached.push(detachDirectoryEntry(entry));
1598
1617
  }
1599
1618
  for (const entry of held) this.directory.delete(entry.provider);
1600
1619
  for (const entry of detached) this.directory.set(entry.provider, entry);
@@ -1623,10 +1642,7 @@ var LlmError = class extends HarnessError {
1623
1642
  * @returns detached directory entries in declaration order.
1624
1643
  */
1625
1644
  listConfigurableProviders() {
1626
- return [...this.directory.values()].map((entry) => ({
1627
- ...entry,
1628
- settingsPath: [...entry.settingsPath]
1629
- }));
1645
+ return [...this.directory.values()].map(detachDirectoryEntry);
1630
1646
  }
1631
1647
  /**
1632
1648
  * Offer to interrogate provider endpoints on behalf of the settings
@@ -1718,6 +1734,16 @@ var LlmError = class extends HarnessError {
1718
1734
  return this.adapters.get(provider)?.adapter.imageRequestPricing(provider, model);
1719
1735
  }
1720
1736
  /**
1737
+ * Resolve the image projection for an exact registered model route.
1738
+ * @param provider - registered provider route.
1739
+ * @param model - exact model id.
1740
+ * @param image - normalized image reference.
1741
+ * @returns dimensions and byte target used by the adapter's request serializer.
1742
+ */
1743
+ imageRequestTarget(provider, model, image) {
1744
+ return this.registration(provider).adapter.imageRequestTarget(provider, model, image);
1745
+ }
1746
+ /**
1721
1747
  * Resolve the exact text one durable file occurrence contributes to every
1722
1748
  * provider request in the current execution environment.
1723
1749
  * @param ref - durable verbatim file reference from model history.
@@ -1863,20 +1889,33 @@ var LlmError = class extends HarnessError {
1863
1889
  * Resolve one call under its current adapter registration. The returned
1864
1890
  * one-shot handle keeps that registration across header logging and dispatch,
1865
1891
  * so HMR cannot combine one adapter's capability result with another adapter.
1866
- * @param config - provider/model route and optional request controls.
1892
+ * An optional synchronous callback selects concrete controls using captured
1893
+ * model metadata. Defaults and validation apply to its result. Callback
1894
+ * failures and cancellation reject preparation before dispatch.
1895
+ * @param config - provider/model route and optional concrete request controls.
1867
1896
  * @param signal - optional cancellation for adapter-owned capability lookup.
1897
+ * @param configure - pure control selection, called once before defaults and validation.
1868
1898
  * @returns a prepared config and its registration-bound stream entry point.
1869
1899
  */
1870
- async prepareCall(config, signal) {
1871
- const registration = this.registration(config.provider);
1872
- const adapterCall = await registration.adapter.prepareCall(config.provider, config.model, signal);
1873
- const modelInfo = this.normalizeModelInfo(registration, config.model, adapterCall.model);
1874
- const resolved = this.resolveCallWithInfo(config, modelInfo);
1900
+ async prepareCall(config, signal, configure) {
1901
+ signal?.throwIfAborted();
1902
+ const { provider, model, ...controls } = config;
1903
+ const registration = this.registration(provider);
1904
+ const adapterCall = await registration.adapter.prepareCall(provider, model, signal);
1905
+ signal?.throwIfAborted();
1906
+ const modelInfo = this.normalizeModelInfo(registration, model, adapterCall.model);
1907
+ const proposed = configure === void 0 ? config : {
1908
+ ...configure(deepFreeze(structuredClone(controls)), deepFreeze(modelInfo)),
1909
+ provider,
1910
+ model
1911
+ };
1912
+ signal?.throwIfAborted();
1913
+ const resolved = this.resolveCallWithInfo(proposed, modelInfo);
1875
1914
  const resolvedConfig = deepFreeze(structuredClone(resolved.config));
1876
1915
  const context = resolved.context === void 0 ? void 0 : deepFreeze(structuredClone(resolved.context));
1877
1916
  const adapterDefaults = deepFreeze({
1878
- ...config.reasoningEffort === void 0 && resolvedConfig.reasoningEffort !== void 0 ? { reasoningEffort: true } : {},
1879
- ...config.maxTokens === void 0 && resolvedConfig.maxTokens !== void 0 ? { maxTokens: true } : {}
1917
+ ...proposed.reasoningEffort === void 0 && resolvedConfig.reasoningEffort !== void 0 ? { reasoningEffort: true } : {},
1918
+ ...proposed.maxTokens === void 0 && resolvedConfig.maxTokens !== void 0 ? { maxTokens: true } : {}
1880
1919
  });
1881
1920
  let dispatched = false;
1882
1921
  return Object.freeze({
@@ -2053,6 +2092,19 @@ function adapterFailureChunk(error, signal) {
2053
2092
  }
2054
2093
  };
2055
2094
  }
2095
+ /** Copy a directory entry, including its arrays, so neither side can mutate the other's copy. */
2096
+ function detachDirectoryEntry(entry) {
2097
+ const { nativeAuth } = entry;
2098
+ return {
2099
+ ...entry,
2100
+ settingsPath: [...entry.settingsPath],
2101
+ ...entry.baseURLEnv === void 0 ? {} : { baseURLEnv: [...entry.baseURLEnv] },
2102
+ ...nativeAuth === void 0 ? {} : { nativeAuth: {
2103
+ ...nativeAuth,
2104
+ env: [...nativeAuth.env]
2105
+ } }
2106
+ };
2107
+ }
2056
2108
  //#endregion
2057
2109
  //#region lib/types/index.js
2058
2110
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-tmux-context",
3
3
  "description": "Opt-in durable per-step context with this agent's tmux pane and window location",
4
- "version": "0.2.1-alpha.1",
4
+ "version": "0.2.1-alpha.3",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,24 +27,24 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "zod": "^4.4.3",
31
- "@deepseek-ai/schemastery": "~3.18.5-alpha.1"
30
+ "@deepseek-ai/schemastery": "~3.18.5-alpha.2",
31
+ "zod": "4.4.3"
32
32
  },
33
33
  "peerDependencies": {
34
- "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
35
- "@deepseek-ai/dsh-shell": "0.2.1-alpha.1",
36
- "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
37
- "@deepseek-ai/cordis": "~4.0.5-alpha.1",
38
- "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.1"
34
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.3",
35
+ "@deepseek-ai/dsh-shell": "0.2.1-alpha.3",
36
+ "@deepseek-ai/dsh-session": "0.2.1-alpha.3",
37
+ "@deepseek-ai/cordis": "~4.0.5-alpha.2",
38
+ "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.3"
39
39
  },
40
40
  "devDependencies": {
41
- "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
42
- "@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.1",
43
- "@deepseek-ai/dsh-shell": "0.2.1-alpha.1",
44
- "@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
45
- "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.1",
46
- "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.1",
47
- "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
48
- "@deepseek-ai/cordis": "~4.0.5-alpha.1"
41
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.3",
42
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.3",
43
+ "@deepseek-ai/dsh-shell": "0.2.1-alpha.3",
44
+ "@deepseek-ai/dsh-llm": "0.2.1-alpha.3",
45
+ "@deepseek-ai/dsh-session": "0.2.1-alpha.3",
46
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.3",
47
+ "@deepseek-ai/cordis": "~4.0.5-alpha.2",
48
+ "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.3"
49
49
  }
50
50
  }