@d3ara1n/pi-model-roles 0.5.0 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d3ara1n/pi-model-roles",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Model role configuration library for pi extensions — defines named model roles and resolves them to Model instances",
6
6
  "main": "src/index.ts",
package/src/api.ts CHANGED
@@ -168,6 +168,10 @@ export function initModelRolesAPI(
168
168
  const { model: _omitModel, ...streamOptions } = options ?? {};
169
169
  if (auth.apiKey) streamOptions.apiKey = auth.apiKey;
170
170
  if (auth.headers) streamOptions.headers = auth.headers;
171
+ // Apply the role's thinking level unless the caller explicitly overrides it.
172
+ if (roleConfig.thinking && streamOptions.reasoningEffort === undefined) {
173
+ streamOptions.reasoningEffort = roleConfig.thinking;
174
+ }
171
175
  return piAiComplete(model, context, streamOptions);
172
176
  },
173
177
 
@@ -188,6 +192,10 @@ export function initModelRolesAPI(
188
192
  const { model: _omitModel, ...streamOptions } = options ?? {};
189
193
  if (auth.apiKey) streamOptions.apiKey = auth.apiKey;
190
194
  if (auth.headers) streamOptions.headers = auth.headers;
195
+ // Apply the role's thinking level unless the caller explicitly overrides it.
196
+ if (roleConfig.thinking && streamOptions.reasoning === undefined) {
197
+ streamOptions.reasoning = roleConfig.thinking;
198
+ }
191
199
  return piAiStreamSimple(model, context, streamOptions);
192
200
  },
193
201
  };
package/src/types.ts CHANGED
@@ -112,15 +112,17 @@ export interface ModelRolesAPI {
112
112
  * Call pi-ai's complete() with auth resolved internally from the role's model.
113
113
  *
114
114
  * Auth (including OAuth token refresh) is resolved for the model actually
115
- * used, so callers never handle API keys or headers. The underlying call is
116
- * pi-ai's complete() verbatim no fallback, no retry, no error swallowing;
115
+ * used, so callers never handle API keys or headers. The role's
116
+ * {@link RoleConfig.thinking} level is applied as `reasoningEffort` unless
117
+ * the caller sets it explicitly. No fallback, no retry, no error swallowing;
117
118
  * throws if the role has no available model or auth resolution fails.
118
119
  *
119
- * @param roleName - Role whose model + auth to use
120
+ * @param roleName - Role whose model + auth + thinking to use
120
121
  * @param context - Conversation context (systemPrompt + messages)
121
122
  * @param options - Stream options forwarded to pi-ai's complete(). Pass
122
123
  * `model` to override the role's model (auth is then resolved for that
123
- * model); all other fields pass through unchanged.
124
+ * model); pass `reasoningEffort` to override the role's thinking level;
125
+ * all other fields pass through unchanged.
124
126
  */
125
127
  complete<TApi extends Api = Api>(
126
128
  roleName: string,
@@ -132,17 +134,20 @@ export interface ModelRolesAPI {
132
134
  * Call pi-ai's streamSimple() with auth resolved internally from the role's model.
133
135
  *
134
136
  * Streaming counterpart to {@link complete}. Same auth resolution (including
135
- * OAuth token refresh) and same error semantics (throws on no model / auth
136
- * failure). Returns the pi-ai event stream verbatim — iterate it for events,
137
- * call `.result()` for the final AssistantMessage.
137
+ * OAuth token refresh), same thinking-level application (role's
138
+ * {@link RoleConfig.thinking} `reasoning` unless overridden), and same
139
+ * error semantics (throws on no model / auth failure). Returns the pi-ai
140
+ * event stream — iterate it for events, call `.result()` for the final
141
+ * AssistantMessage.
138
142
  *
139
143
  * Note: unlike pi-ai's synchronous `streamSimple`, this is async because auth
140
144
  * resolution (OAuth token refresh) must complete before the stream starts.
141
145
  *
142
- * @param roleName - Role whose model + auth to use
146
+ * @param roleName - Role whose model + auth + thinking to use
143
147
  * @param context - Conversation context (systemPrompt + messages)
144
148
  * @param options - Stream options forwarded to pi-ai's streamSimple(). Pass
145
- * `model` to override the role's model; all other fields pass through.
149
+ * `model` to override the role's model; pass `reasoning` to override the
150
+ * role's thinking level; all other fields pass through.
146
151
  */
147
152
  streamWithRole<TApi extends Api = Api>(
148
153
  roleName: string,