mainsequence 9.0.2.dev32__py3-none-any.whl → 9.0.3.dev33__py3-none-any.whl
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.
- agent_scaffold/AGENTS.md +3 -0
- agent_scaffold/skills/mainsequence-inference/SKILL.md +198 -0
- agent_scaffold/skills/sdk_code_repository_execution/SKILL.md +3 -0
- mainsequence/cli/api.py +1 -1
- mainsequence/cli/cli.py +1 -1
- mainsequence/client/__init__.py +12 -0
- mainsequence/client/inference.py +184 -0
- {mainsequence-9.0.2.dev32.dist-info → mainsequence-9.0.3.dev33.dist-info}/METADATA +1 -1
- {mainsequence-9.0.2.dev32.dist-info → mainsequence-9.0.3.dev33.dist-info}/RECORD +13 -11
- {mainsequence-9.0.2.dev32.dist-info → mainsequence-9.0.3.dev33.dist-info}/WHEEL +0 -0
- {mainsequence-9.0.2.dev32.dist-info → mainsequence-9.0.3.dev33.dist-info}/entry_points.txt +0 -0
- {mainsequence-9.0.2.dev32.dist-info → mainsequence-9.0.3.dev33.dist-info}/licenses/LICENSE +0 -0
- {mainsequence-9.0.2.dev32.dist-info → mainsequence-9.0.3.dev33.dist-info}/top_level.txt +0 -0
agent_scaffold/AGENTS.md
CHANGED
|
@@ -83,6 +83,9 @@ bundle. Platform skills are installed separately under
|
|
|
83
83
|
`.agents/skills/mainsequence/platform_operations/orchestration_and_releases/SKILL.md`
|
|
84
84
|
- RBAC, sharing, constants, secrets, and access verification:
|
|
85
85
|
`.agents/skills/mainsequence/platform_operations/access_control_and_sharing/SKILL.md`
|
|
86
|
+
- Direct recorded model calls, structured extraction, thinking/provider options,
|
|
87
|
+
inference history and idempotent replay:
|
|
88
|
+
`.agents/skills/mainsequence/mainsequence-inference/SKILL.md`
|
|
86
89
|
- A2A session discovery, messages, files, and SDK response handling:
|
|
87
90
|
`.agents/skills/mainsequence/a2a_sdk_execution/SKILL.md`
|
|
88
91
|
- Turning a CodeRepository into a platform coding agent or selecting other
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mainsequence-inference
|
|
3
|
+
description: Use the Main Sequence Python SDK for direct recorded model completions and structured extraction, with thinking levels, provider-native options, conversation history and safe replay. Use for model calls that do not need an Agent or A2A session.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Main Sequence Recorded Inference
|
|
7
|
+
|
|
8
|
+
Use `mainsequence.client.InferenceClient` to call the recorded inference endpoint.
|
|
9
|
+
Main Sequence authenticates the caller, uses existing stored provider credentials,
|
|
10
|
+
and records input/output. No Agent, AgentSession, Tau runtime or application-side
|
|
11
|
+
provider key is required. This skill teaches the SDK client; the platform owns
|
|
12
|
+
provider availability, permissions and execution behavior.
|
|
13
|
+
|
|
14
|
+
## Establish the client and model
|
|
15
|
+
|
|
16
|
+
Use the installed `mainsequence.client.inference` implementation and its matching
|
|
17
|
+
[inference documentation](https://mainsequence-sdk.github.io/mainsequence-sdk/knowledge/infrastructure/inference/).
|
|
18
|
+
If the installed SDK lacks `InferenceClient`, report the missing capability. Do
|
|
19
|
+
not silently upgrade the SDK, restore retired `Agent.respond` calls, or replace
|
|
20
|
+
recorded inference with direct provider HTTP calls.
|
|
21
|
+
|
|
22
|
+
Reuse existing Main Sequence authentication and the current provider catalog.
|
|
23
|
+
Select an exact available provider/model with configured credentials; examples
|
|
24
|
+
below illustrate request shapes, not a guarantee that an account can use a model.
|
|
25
|
+
There is no inference CLI command; use the Python client.
|
|
26
|
+
|
|
27
|
+
For local CodeRepository code using human credentials, resolve the Environment
|
|
28
|
+
from the current Git checkout through the existing SDK context:
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from mainsequence.client import InferenceClient
|
|
32
|
+
from mainsequence.code_repository_context import get_code_repository_context
|
|
33
|
+
|
|
34
|
+
context = get_code_repository_context()
|
|
35
|
+
if context.organization_environment_uid is None:
|
|
36
|
+
raise RuntimeError("This checkout has no resolved Organization Environment")
|
|
37
|
+
client = InferenceClient(
|
|
38
|
+
organization_environment_uid=context.organization_environment_uid,
|
|
39
|
+
)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For an authenticated deployed runtime, use `InferenceClient()`; the server derives
|
|
43
|
+
its exact Environment. A contradictory selector fails. Outside a CodeRepository,
|
|
44
|
+
human callers provide an authorized Environment UID from their application
|
|
45
|
+
context. Never invent an Environment, use another branch as a fallback, or add
|
|
46
|
+
inference environment variables. Provider secrets remain in existing server-side
|
|
47
|
+
credential storage and must not appear in messages or `provider_options`.
|
|
48
|
+
|
|
49
|
+
## Construct a completion envelope
|
|
50
|
+
|
|
51
|
+
Every call supplies complete ordered text messages: `system`, `user`, `assistant`.
|
|
52
|
+
Earlier requests are never automatically prepended. An omitted `conversation_uid`
|
|
53
|
+
creates a conversation; an existing UID groups another independent request with
|
|
54
|
+
its own full context. Each new logical call needs its own idempotency key.
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
def extract_weight(client, document, *, idempotency_key, conversation_uid=None):
|
|
58
|
+
return client.complete(
|
|
59
|
+
provider="openai",
|
|
60
|
+
model="gpt-5.4", # Replace with the exact available catalog selection.
|
|
61
|
+
messages=[
|
|
62
|
+
{"role": "system", "content": "Extract the fund weight as a fraction."},
|
|
63
|
+
{"role": "user", "content": document},
|
|
64
|
+
],
|
|
65
|
+
thinking_level="high",
|
|
66
|
+
provider_options={"store": False, "text": {"verbosity": "low"}},
|
|
67
|
+
response_schema={
|
|
68
|
+
"type": "object",
|
|
69
|
+
"properties": {"weight": {"type": "number"}},
|
|
70
|
+
"required": ["weight"],
|
|
71
|
+
"additionalProperties": False,
|
|
72
|
+
},
|
|
73
|
+
metadata={"operation": "fund-weight-extraction"},
|
|
74
|
+
conversation_uid=conversation_uid,
|
|
75
|
+
idempotency_key=idempotency_key,
|
|
76
|
+
)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`response_schema`, `thinking_level`, `provider_options`, `provider_storage`,
|
|
80
|
+
`metadata` and `conversation_uid` are optional. Metadata is recorded content,
|
|
81
|
+
not authorization or a credential selector. Keep sensitive payloads out of logs.
|
|
82
|
+
The current contract accepts bounded text/JSON; it does not execute tools, stream,
|
|
83
|
+
fetch document URLs, or accept file/image attachments. Extract document text first.
|
|
84
|
+
|
|
85
|
+
Only consume `result.output["content"]` when `result.status == "completed"`,
|
|
86
|
+
`result.content_available` is true, and `result.output` is present.
|
|
87
|
+
A validated common `response_schema` returns parsed JSON there; ordinary text
|
|
88
|
+
completions return a string. A replay can return a pending result without output.
|
|
89
|
+
Preserve `conversation_uid` and `request_uid` from `InferenceResult` for inspection.
|
|
90
|
+
|
|
91
|
+
## Thinking and native provider options
|
|
92
|
+
|
|
93
|
+
`thinking_level` accepts the catalog vocabulary `off`, `minimal`, `low`, `medium`,
|
|
94
|
+
`high`, `xhigh`, but the exact model and adapter must support the requested level.
|
|
95
|
+
Unsupported mappings fail; do not silently lower the level to make a call work.
|
|
96
|
+
Omitting the field preserves native thinking options, or the provider default
|
|
97
|
+
when none are supplied. `off` is an explicit selection, not omission.
|
|
98
|
+
|
|
99
|
+
Use `provider_options` for native JSON body fields the caller knows. Objects,
|
|
100
|
+
arrays, numbers, false and null are preserved. Disjoint nested fields merge;
|
|
101
|
+
colliding explicit common/native controls fail even when their values agree.
|
|
102
|
+
Do not combine `thinking_level` with native thinking selection or
|
|
103
|
+
`provider_storage.store_response` with native `store`. Omit the corresponding
|
|
104
|
+
common convenience when choosing native configuration.
|
|
105
|
+
|
|
106
|
+
| Family | Native `provider_options` example | Meaning |
|
|
107
|
+
| --- | --- | --- |
|
|
108
|
+
| OpenAI Responses | `{"reasoning": {"effort": "high"}, "store": false, "text": {"verbosity": "low"}}` | Native reasoning and storage; Chat Completions uses `reasoning_effort` instead. The catalog chooses the API. |
|
|
109
|
+
| Anthropic Messages | `{"thinking": {"type": "adaptive"}, "output_config": {"effort": "high"}, "max_tokens": 4096}` | For an adaptive model; older models can use their native thinking budget. Do not send an invented OpenAI `store` flag. |
|
|
110
|
+
| Ollama compatible API | `{"reasoning_effort": "high"}` | Select the existing Organization custom-provider identifier and a compatible model/API. Native Ollama `/api/chat` fields are not automatically translated. |
|
|
111
|
+
| OpenRouter Chat | `{"reasoning": {"effort": "high"}, "provider": {"require_parameters": true, "zdr": true}}` | The nested `provider` object is upstream routing, distinct from the top-level catalog selector. ZDR routing is not proof of account-wide zero retention. |
|
|
112
|
+
|
|
113
|
+
These are independent native-only examples: omit `thinking_level` when using
|
|
114
|
+
them. Main Sequence forwards accepted native fields without inventing a normalized
|
|
115
|
+
thinking level or claiming a provider honored an unknown option. Native fields
|
|
116
|
+
cannot override the canonical model/input, credentials, endpoint, headers,
|
|
117
|
+
streaming/background lifecycle, provider continuation, tool execution or alternate
|
|
118
|
+
model selection. Common OpenRouter thinking/schema controls already add
|
|
119
|
+
`provider.require_parameters`; do not also set that path in native options.
|
|
120
|
+
|
|
121
|
+
## Provider storage versus Main Sequence history
|
|
122
|
+
|
|
123
|
+
**Main Sequence keeps every admitted conversation exchange until explicitly
|
|
124
|
+
deleted.** Provider storage controls never disable this history. Do not add an
|
|
125
|
+
expiry setting, capture opt-in, `record_history=False`, or a new policy registry.
|
|
126
|
+
|
|
127
|
+
- OpenAI: `provider_storage={"store_response": False}` compiles to `store: false`.
|
|
128
|
+
Choose this convenience or native `provider_options={"store": False}`.
|
|
129
|
+
- Anthropic: `store_response=False` means the stateless Messages contract. It
|
|
130
|
+
does not promise that operational logs or caches do not exist.
|
|
131
|
+
- Ollama and OpenRouter: the common storage convenience is not supported as a
|
|
132
|
+
universal per-request guarantee. Use supported native/account controls; do not
|
|
133
|
+
add or drop flags silently. Ollama is configured through existing custom
|
|
134
|
+
providers; `keep_alive` governs model residency, not conversation retention.
|
|
135
|
+
- `provider_storage={"require_zero_data_retention": True}` currently rejects
|
|
136
|
+
before dispatch because verified account eligibility is unavailable. Neither
|
|
137
|
+
OpenAI `store: false` nor OpenRouter `provider.zdr` establishes that guarantee.
|
|
138
|
+
|
|
139
|
+
## Handle outcomes and replay
|
|
140
|
+
|
|
141
|
+
Create and persist the key with the application's logical request **before** its
|
|
142
|
+
first submission. Keys contain 1–128 letters, digits, `.`, `_`, `:` or `-`. Do not
|
|
143
|
+
put key generation inside a retry loop. Preserve the exact envelope for replay,
|
|
144
|
+
including conversation creation/attachment, model, thinking, native options,
|
|
145
|
+
metadata and schema. Reuse the same User, Environment and authenticated workload;
|
|
146
|
+
idempotency is scoped to that context, not global across unrelated JobRuns.
|
|
147
|
+
|
|
148
|
+
- `InferenceExecutionError` exposes `result` and `status_code`. Retain the
|
|
149
|
+
returned IDs and inspect `client.request(error.result.request_uid)`. Invalid
|
|
150
|
+
structured output, provider failure and unknown outcomes are not successes.
|
|
151
|
+
- `InferenceTransportError` retains `idempotency_key`; the outcome may already
|
|
152
|
+
be recorded or executing. Inspect known request/history IDs, or explicitly
|
|
153
|
+
replay the identical envelope and key. Never substitute a new key after an
|
|
154
|
+
ambiguous result. Lower-level HTTP failures also do not justify a fresh key.
|
|
155
|
+
- `admitted`/`dispatching` means pending; `completed` means persisted success;
|
|
156
|
+
`failed`/`unknown` requires inspection. Replaying unknown work does not execute
|
|
157
|
+
again. A changed envelope with the same key conflicts (409); deleted content
|
|
158
|
+
yields a recorded 410. Do not hide these cases behind an automatic retry loop.
|
|
159
|
+
|
|
160
|
+
The client does not automatically retry network failures. It permits one refresh
|
|
161
|
+
following an explicit authentication 401, preserving body and key. A longer
|
|
162
|
+
client `timeout` does not extend the server's execution deadline. Neither a
|
|
163
|
+
transport timeout nor `unknown` proves the provider stopped processing.
|
|
164
|
+
Missing usage remains unknown; inspect `usage["complete"]` where present instead
|
|
165
|
+
of treating absent token counts as a free call. Native-only structured output
|
|
166
|
+
is not automatically validated by the common `response_schema` validator.
|
|
167
|
+
|
|
168
|
+
## Read history and delete only when requested
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
conversations = client.conversations(limit=25, offset=0)
|
|
172
|
+
conversation = client.conversation(result.conversation_uid)
|
|
173
|
+
request = client.request(result.request_uid)
|
|
174
|
+
history = client.history(result.conversation_uid, limit=25, offset=0)
|
|
175
|
+
insights = client.insights(result.conversation_uid)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Lists/history return `count`, `next`, `previous`, `results`; request retrieval
|
|
179
|
+
returns `InferenceResult`. History records each complete submitted context and its
|
|
180
|
+
output in admission order, not model-managed memory. Insights summarize outcomes,
|
|
181
|
+
submitted messages and known tokens with unknown-usage counts. Read methods never
|
|
182
|
+
invoke the model. The owner and authorized same-Organization administrators can
|
|
183
|
+
inspect content within the admitted Environment; only the owner can append.
|
|
184
|
+
|
|
185
|
+
For an explicit content-deletion request, use
|
|
186
|
+
`client.delete_content(conversation_uid)`. It removes protected inputs, outputs,
|
|
187
|
+
schemas and options, while keeping request identity and non-content outcome/usage
|
|
188
|
+
records. Replay never reconstructs deleted content or runs the provider again,
|
|
189
|
+
even if a response arrives after deletion. Do not schedule automatic deletion.
|
|
190
|
+
|
|
191
|
+
## Verify an integration
|
|
192
|
+
|
|
193
|
+
Mock the provider-facing boundary or SDK transport for local tests. Check the
|
|
194
|
+
chosen thinking/native envelope, parsed structured result, stable retry identity,
|
|
195
|
+
pending/error handling and history retrieval. Make a live provider call only
|
|
196
|
+
when the task authorizes it and the existing account is ready; a successful call
|
|
197
|
+
does not verify the provider's retention practices. Report mocked versus live
|
|
198
|
+
verification clearly.
|
|
@@ -60,6 +60,9 @@ Do not let this skill become a domain manual.
|
|
|
60
60
|
`.agents/skills/mainsequence/platform_operations/orchestration_and_releases/SKILL.md`
|
|
61
61
|
- RBAC and sharing:
|
|
62
62
|
`.agents/skills/mainsequence/platform_operations/access_control_and_sharing/SKILL.md`
|
|
63
|
+
- direct recorded inference, structured extraction, thinking/provider controls,
|
|
64
|
+
conversation history and safe replay:
|
|
65
|
+
`.agents/skills/mainsequence/mainsequence-inference/SKILL.md`
|
|
63
66
|
- TAU-based Harness Agent repository integration, local development, project
|
|
64
67
|
customization, and runtime A2A adaptation: use the version-matched skills in
|
|
65
68
|
`.agents/skills/ms_tau_sdk/` after the platform-owned skill defines the
|
mainsequence/cli/api.py
CHANGED
|
@@ -810,7 +810,7 @@ def get_logged_user_details() -> dict[str, Any]:
|
|
|
810
810
|
organization.pop("id", None)
|
|
811
811
|
return user
|
|
812
812
|
if hasattr(user, "model_dump"):
|
|
813
|
-
payload = user.model_dump()
|
|
813
|
+
payload = user.model_dump(mode="json")
|
|
814
814
|
payload.pop("id", None)
|
|
815
815
|
organization = payload.get("organization")
|
|
816
816
|
if isinstance(organization, dict):
|
mainsequence/cli/cli.py
CHANGED
|
@@ -285,7 +285,7 @@ def _to_jsonable(value):
|
|
|
285
285
|
return [_to_jsonable(item) for item in value]
|
|
286
286
|
if isinstance(value, datetime.datetime | datetime.date | datetime.time):
|
|
287
287
|
return value.isoformat()
|
|
288
|
-
if isinstance(value, pathlib.Path):
|
|
288
|
+
if isinstance(value, pathlib.Path | uuid.UUID):
|
|
289
289
|
return str(value)
|
|
290
290
|
if isinstance(value, PyEnum):
|
|
291
291
|
return value.value
|
mainsequence/client/__init__.py
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
from mainsequence.logconf import logger as logger
|
|
2
2
|
|
|
3
3
|
from .github_issues import * # noqa: F403
|
|
4
|
+
from .inference import (
|
|
5
|
+
InferenceClient as InferenceClient,
|
|
6
|
+
)
|
|
7
|
+
from .inference import (
|
|
8
|
+
InferenceExecutionError as InferenceExecutionError,
|
|
9
|
+
)
|
|
10
|
+
from .inference import (
|
|
11
|
+
InferenceResult as InferenceResult,
|
|
12
|
+
)
|
|
13
|
+
from .inference import (
|
|
14
|
+
InferenceTransportError as InferenceTransportError,
|
|
15
|
+
)
|
|
4
16
|
from .models_foundry import * # noqa: F403
|
|
5
17
|
from .models_helpers import * # noqa: F403
|
|
6
18
|
from .models_user import * # noqa: F403
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"""Recorded model calls through Main Sequence's authenticated API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from copy import deepcopy
|
|
6
|
+
from typing import Any
|
|
7
|
+
from uuid import UUID
|
|
8
|
+
|
|
9
|
+
import requests
|
|
10
|
+
from pydantic import BaseModel, ConfigDict, Field, ValidationError
|
|
11
|
+
|
|
12
|
+
from . import utils
|
|
13
|
+
from .exceptions import raise_for_response
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class InferenceResult(BaseModel):
|
|
17
|
+
model_config = ConfigDict(extra="allow")
|
|
18
|
+
conversation_uid: str
|
|
19
|
+
request_uid: str
|
|
20
|
+
sequence: int
|
|
21
|
+
provider: str
|
|
22
|
+
model: str
|
|
23
|
+
status: str
|
|
24
|
+
error_code: str
|
|
25
|
+
content_available: bool
|
|
26
|
+
usage: dict[str, Any] = Field(default_factory=dict)
|
|
27
|
+
input: dict[str, Any] | None = None
|
|
28
|
+
output: dict[str, Any] | None = None
|
|
29
|
+
effective_controls: dict[str, Any] = Field(default_factory=dict)
|
|
30
|
+
provider_error: dict[str, Any] | None = None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class InferenceExecutionError(RuntimeError):
|
|
34
|
+
"""A recorded failure; inspect ``result.request_uid`` without re-executing."""
|
|
35
|
+
|
|
36
|
+
def __init__(self, result: InferenceResult, status_code: int):
|
|
37
|
+
self.result = result
|
|
38
|
+
self.status_code = status_code
|
|
39
|
+
super().__init__(result.error_code or result.status)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class InferenceTransportError(RuntimeError):
|
|
43
|
+
"""Outcome is uncertain. Replay the same body and idempotency key only."""
|
|
44
|
+
|
|
45
|
+
def __init__(self, idempotency_key: str | None):
|
|
46
|
+
self.idempotency_key = idempotency_key
|
|
47
|
+
super().__init__(
|
|
48
|
+
"The request outcome is unknown. Inspect history or replay the identical request with the same idempotency key."
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class InferenceClient:
|
|
53
|
+
"""Full caller-supplied context, with durable history and no Agent dependency.
|
|
54
|
+
|
|
55
|
+
Runtime credentials derive their Environment on the server. Human callers
|
|
56
|
+
provide ``organization_environment_uid`` explicitly. Provider secrets never
|
|
57
|
+
pass through this client. Optional provider options retain native JSON values.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
def __init__(self, *, organization_environment_uid: str | UUID | None = None):
|
|
61
|
+
self.organization_environment_uid = (
|
|
62
|
+
str(UUID(str(organization_environment_uid)))
|
|
63
|
+
if organization_environment_uid is not None
|
|
64
|
+
else None
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
def _request(self, method, path, *, body=None, key=None, params=None, timeout=100):
|
|
68
|
+
query = dict(params or {})
|
|
69
|
+
if self.organization_environment_uid is not None:
|
|
70
|
+
query["organization_environment_uid"] = self.organization_environment_uid
|
|
71
|
+
url = f"{utils.API_ENDPOINT.rstrip('/')}/{path}"
|
|
72
|
+
# The shared make_request loop retries network failures. Inference uses
|
|
73
|
+
# the same auth loader with a dedicated zero-retry transport instead.
|
|
74
|
+
with utils.build_session(loaders=utils.loaders, retries=0) as session:
|
|
75
|
+
headers = dict(utils.loaders.refresh_headers(force=False, session=session))
|
|
76
|
+
if key is not None:
|
|
77
|
+
headers["Idempotency-Key"] = key
|
|
78
|
+
try:
|
|
79
|
+
response = session.request(
|
|
80
|
+
method,
|
|
81
|
+
url,
|
|
82
|
+
headers=headers,
|
|
83
|
+
params=query,
|
|
84
|
+
json=body,
|
|
85
|
+
timeout=timeout,
|
|
86
|
+
allow_redirects=False,
|
|
87
|
+
)
|
|
88
|
+
if response.status_code == 401:
|
|
89
|
+
headers.update(utils.loaders.refresh_headers(force=True, session=session))
|
|
90
|
+
response = session.request(
|
|
91
|
+
method,
|
|
92
|
+
url,
|
|
93
|
+
headers=headers,
|
|
94
|
+
params=query,
|
|
95
|
+
json=body,
|
|
96
|
+
timeout=timeout,
|
|
97
|
+
allow_redirects=False,
|
|
98
|
+
)
|
|
99
|
+
except requests.RequestException as exc:
|
|
100
|
+
raise InferenceTransportError(key) from exc
|
|
101
|
+
if method == "POST":
|
|
102
|
+
try:
|
|
103
|
+
payload = response.json()
|
|
104
|
+
except ValueError as exc:
|
|
105
|
+
raise_for_response(response)
|
|
106
|
+
raise InferenceTransportError(key) from exc
|
|
107
|
+
if isinstance(payload, dict) and "request_uid" in payload:
|
|
108
|
+
try:
|
|
109
|
+
result = InferenceResult.model_validate(payload)
|
|
110
|
+
except ValidationError as exc:
|
|
111
|
+
raise InferenceTransportError(key) from exc
|
|
112
|
+
if response.status_code >= 400:
|
|
113
|
+
raise InferenceExecutionError(result, response.status_code)
|
|
114
|
+
return result
|
|
115
|
+
raise_for_response(response)
|
|
116
|
+
raise InferenceTransportError(key)
|
|
117
|
+
raise_for_response(response)
|
|
118
|
+
return response.json()
|
|
119
|
+
|
|
120
|
+
def complete(
|
|
121
|
+
self,
|
|
122
|
+
*,
|
|
123
|
+
provider: str,
|
|
124
|
+
model: str,
|
|
125
|
+
messages: list[dict[str, str]],
|
|
126
|
+
idempotency_key: str,
|
|
127
|
+
conversation_uid: str | UUID | None = None,
|
|
128
|
+
thinking_level: str | None = None,
|
|
129
|
+
provider_options: dict[str, Any] | None = None,
|
|
130
|
+
provider_storage: dict[str, Any] | None = None,
|
|
131
|
+
response_schema: dict[str, Any] | None = None,
|
|
132
|
+
metadata: dict[str, Any] | None = None,
|
|
133
|
+
timeout: float = 100,
|
|
134
|
+
) -> InferenceResult:
|
|
135
|
+
"""Execute once or replay an existing identity; never generate a retry key."""
|
|
136
|
+
import re
|
|
137
|
+
|
|
138
|
+
if not isinstance(idempotency_key, str) or not re.fullmatch(
|
|
139
|
+
r"[A-Za-z0-9._:-]{1,128}", idempotency_key
|
|
140
|
+
):
|
|
141
|
+
raise ValueError(
|
|
142
|
+
"idempotency_key must contain 1–128 letters, digits, dots, underscores, colons or hyphens."
|
|
143
|
+
)
|
|
144
|
+
body = {"provider": provider, "model": model, "messages": deepcopy(messages)}
|
|
145
|
+
if conversation_uid is not None:
|
|
146
|
+
body["conversation_uid"] = str(UUID(str(conversation_uid)))
|
|
147
|
+
for name, value in (
|
|
148
|
+
("thinking_level", thinking_level),
|
|
149
|
+
("provider_options", provider_options),
|
|
150
|
+
("provider_storage", provider_storage),
|
|
151
|
+
("response_schema", response_schema),
|
|
152
|
+
("metadata", metadata),
|
|
153
|
+
):
|
|
154
|
+
if value is not None:
|
|
155
|
+
body[name] = deepcopy(value)
|
|
156
|
+
return self._request(
|
|
157
|
+
"POST", "inference/completions/", body=body, key=idempotency_key, timeout=timeout
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
def conversations(self, *, limit: int = 25, offset: int = 0) -> dict[str, Any]:
|
|
161
|
+
return self._request(
|
|
162
|
+
"GET", "inference/conversations/", params={"limit": limit, "offset": offset}
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
def conversation(self, uid: str | UUID) -> dict[str, Any]:
|
|
166
|
+
return self._request("GET", f"inference/conversations/{UUID(str(uid))}/")
|
|
167
|
+
|
|
168
|
+
def history(self, uid: str | UUID, *, limit: int = 25, offset: int = 0) -> dict[str, Any]:
|
|
169
|
+
return self._request(
|
|
170
|
+
"GET",
|
|
171
|
+
f"inference/conversations/{UUID(str(uid))}/history/",
|
|
172
|
+
params={"limit": limit, "offset": offset},
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
def request(self, uid: str | UUID) -> InferenceResult:
|
|
176
|
+
return InferenceResult.model_validate(
|
|
177
|
+
self._request("GET", f"inference/requests/{UUID(str(uid))}/")
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
def insights(self, uid: str | UUID) -> dict[str, Any]:
|
|
181
|
+
return self._request("GET", f"inference/conversations/{UUID(str(uid))}/insights/")
|
|
182
|
+
|
|
183
|
+
def delete_content(self, uid: str | UUID) -> dict[str, Any]:
|
|
184
|
+
return self._request("DELETE", f"inference/conversations/{UUID(str(uid))}/content/")
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
agent_scaffold/AGENTS.md,sha256=
|
|
1
|
+
agent_scaffold/AGENTS.md,sha256=fRFmLrFRhFI6T54YTjPLMeGXXtvwucC3yzDweQ_uycE,6366
|
|
2
2
|
agent_scaffold/skills/a2a_sdk_execution/SKILL.md,sha256=NKtcXibE8TxZzKzz1KzJ2cVZ_EeuJJkb660U6wLvZ3s,11809
|
|
3
3
|
agent_scaffold/skills/application_surfaces/api_surfaces/SKILL.md,sha256=zETXg2fFCujdorOqI2yjhH4Zv1nS16il8uuohF3jz60,13883
|
|
4
|
+
agent_scaffold/skills/mainsequence-inference/SKILL.md,sha256=IrVnpuzFMZ3_x5oSH4OiPZsZ5jFf_aKdxEynrQhnRZE,11627
|
|
4
5
|
agent_scaffold/skills/maintenance/bug_auditor/SKILL.md,sha256=pV8g6FbSgZu1ZsrCaWAbrf6MpetxMqoZKO1rBbtZMgs,8591
|
|
5
6
|
agent_scaffold/skills/maintenance/code_repository_maintenance/SKILL.md,sha256=PczPIOM1YPyXlgd7i5OyN5DkYVwGHrDowsyoxzAqsi8,13396
|
|
6
7
|
agent_scaffold/skills/maintenance/metatables_transition/SKILL.md,sha256=PisgpytcksJnfZMS6aiPCmahsT3fm8DIwk_cefXA2qU,3759
|
|
7
8
|
agent_scaffold/skills/platform_operations/access_control_and_sharing/SKILL.md,sha256=o1rIlYAC7ejV7gKKf-BaglIZY1YkDO5Y27F6e2eK_94,8571
|
|
8
9
|
agent_scaffold/skills/platform_operations/orchestration_and_releases/SKILL.md,sha256=F2I_pwzhbVW-32pBHQZfLnX6BC76iiILHZU1ewy2VYo,15245
|
|
9
|
-
agent_scaffold/skills/sdk_code_repository_execution/SKILL.md,sha256=
|
|
10
|
+
agent_scaffold/skills/sdk_code_repository_execution/SKILL.md,sha256=XjZiRQ-4XCSgcanXvQcSd0BiDvBA9S92-8jpVx79hUs,10189
|
|
10
11
|
mainsequence/__init__.py,sha256=70CbIo7ZG1mzi5uwkqDtVESunBE0RanHjeFg4ptfsA0,385
|
|
11
12
|
mainsequence/__main__.py,sha256=KuAP69uduS2ImrPIgNMzbGBRepZzjqvUONu5vFh4v4A,176
|
|
12
13
|
mainsequence/_request_identity.py,sha256=jiroPFVDM8vphEf9VXuggQJKUOGohfk7-pDwJSOILEw,1211
|
|
@@ -19,9 +20,9 @@ mainsequence/repository_identity_security.py,sha256=Cdywndhiy1zJFUPh-FfM90RjZ3Hg
|
|
|
19
20
|
mainsequence/runtime_flags.py,sha256=1eTM7VRRhnuZ_GXcmFhqAmdEKwyQYMyZcPsio88vJRQ,378
|
|
20
21
|
mainsequence/scaffold_skills.py,sha256=k0V6eKC5AwbHr9wB9UGMJNF-8eJ0_1izF4-BU01KHrg,10606
|
|
21
22
|
mainsequence/cli/__init__.py,sha256=sMWTnomCaISjnureLuXFRqOzkH2Y77uYEivsd-M6_8Y,28
|
|
22
|
-
mainsequence/cli/api.py,sha256=
|
|
23
|
+
mainsequence/cli/api.py,sha256=V_unMemgLaI3PhlhQ3cKngWPMczqwr6QJwbFVBE_55s,128597
|
|
23
24
|
mainsequence/cli/browser_auth.py,sha256=C-Sbpt0Pr9Pv3Z9dO80TMk7zPcaaZ-4zvW0tbRVMrTU,9863
|
|
24
|
-
mainsequence/cli/cli.py,sha256=
|
|
25
|
+
mainsequence/cli/cli.py,sha256=3cL5Xjp6TGgfuBeOHSEoOm5jOH7fEFblla70vTSiX8A,276184
|
|
25
26
|
mainsequence/cli/code_repository_status.py,sha256=SHEnU8YSWFowPG6dEdE4Yd8CS1tIcJSE1MXFLfvD3Os,5975
|
|
26
27
|
mainsequence/cli/config.py,sha256=4AGDEUPAJ1GzoDX3FzYYFvGMKfeAXM38Kh7Yv-OQLQQ,45595
|
|
27
28
|
mainsequence/cli/docker_utils.py,sha256=eAnp9MI042cHWwKasA5IF2I7INL3A6tV2JX-cSIe7rc,10687
|
|
@@ -32,13 +33,14 @@ mainsequence/cli/pydantic_cli.py,sha256=zmFNYv14NrjgXbOszY9qmzDBu-0-J5S2Ado-eMII
|
|
|
32
33
|
mainsequence/cli/sdk_utils.py,sha256=SFuSzh8WDNf21mLiDa51K8Fqe5XiLWh2KhHj8zUjCXo,2701
|
|
33
34
|
mainsequence/cli/ssh_utils.py,sha256=XznLkntuw7HklfuoJax3OpJY2ccsxQHOUBzZtAl05Kc,13472
|
|
34
35
|
mainsequence/cli/ui.py,sha256=memd6pmjALfGj8zndGCx_z80ztQeqTcOvcofU0un34U,2277
|
|
35
|
-
mainsequence/client/__init__.py,sha256=
|
|
36
|
+
mainsequence/client/__init__.py,sha256=lsr9JWxeVqOG0KRoHErW5M40ACPSR7SAEE508dTN5XM,672
|
|
36
37
|
mainsequence/client/agent_runtime_models.py,sha256=lay0DN3lN5p6-3ajVsaHvPgcmrURFwrNfTb6upoImm4,66642
|
|
37
38
|
mainsequence/client/base.py,sha256=T3k3xptM09TreiVogrxAPWoIy8zM6Dtn3Cbwsnb33ag,42678
|
|
38
39
|
mainsequence/client/client.py,sha256=sUsJhjwKq4oZsEX2Ozm-7owcyQq0kgFNKUrtEYwf8cU,3907
|
|
39
40
|
mainsequence/client/compute_validation.py,sha256=ByeX0CkIE7qq06ggZFfN92U3Qp2e9cvo2RTIGWa5_Vw,6662
|
|
40
41
|
mainsequence/client/exceptions.py,sha256=xx2L4l3OMNsTybbYkiTKK398ahnutEascM0It35tGr0,3815
|
|
41
42
|
mainsequence/client/github_issues.py,sha256=pSTUw3UPrmE6wqnpoJctartTaNSq6iu6PQRrd8hip6I,14568
|
|
43
|
+
mainsequence/client/inference.py,sha256=iMg3l5DGW6PQeVkz38Z3lTpxryMO14CTK6gIRHLYUBE,7368
|
|
42
44
|
mainsequence/client/models_foundry.py,sha256=iN1jJzDokfniEQF0Ac5eepAB7L5pVjJnKavaHLP7BHA,36310
|
|
43
45
|
mainsequence/client/models_helpers.py,sha256=rE7wPc9llKkctAKdJcak0kXJagjLivUzO2ebUGhz1M8,45820
|
|
44
46
|
mainsequence/client/models_user.py,sha256=BU_hfn4-4KqYz3nsaPlXuYZmUG6_-7YM892mkM92Zyo,37613
|
|
@@ -50,9 +52,9 @@ mainsequence/instrumentation/utils.py,sha256=b-ihjSioAepeLfMpudM2SqCtvnxMqIXileH
|
|
|
50
52
|
mainsequence/server/__init__.py,sha256=559DiiBcCP6veWRmK2mXUEbsl7gbZofTvsbTUFjn0VE,82
|
|
51
53
|
mainsequence/server/caller_assertions.py,sha256=5q8LZrDYozaonG1eBb9P8DojKQlB2i2qUJwO5VhsrW4,9780
|
|
52
54
|
mainsequence/server/fastapi.py,sha256=tD1aVuJOgoBTu7H8bs9IldPNYRT4fhkr1leN3KZP1pI,10521
|
|
53
|
-
mainsequence-9.0.
|
|
54
|
-
mainsequence-9.0.
|
|
55
|
-
mainsequence-9.0.
|
|
56
|
-
mainsequence-9.0.
|
|
57
|
-
mainsequence-9.0.
|
|
58
|
-
mainsequence-9.0.
|
|
55
|
+
mainsequence-9.0.3.dev33.dist-info/licenses/LICENSE,sha256=b6Ecsk8wjsEby3lbSzdljR6hHiFGHBizt9iWV2p1c_I,1074
|
|
56
|
+
mainsequence-9.0.3.dev33.dist-info/METADATA,sha256=GlRgiFfjsEHypd6iSEZdjUqr4hEBQeBOLfYljbg_9Ec,7435
|
|
57
|
+
mainsequence-9.0.3.dev33.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
58
|
+
mainsequence-9.0.3.dev33.dist-info/entry_points.txt,sha256=XGAOq3-mF2lWWpeRJvoaWyMarRcK167mH1g124aGdUs,88
|
|
59
|
+
mainsequence-9.0.3.dev33.dist-info/top_level.txt,sha256=BFeblM_Q9q0cUWBvTxnfWcWQEHtf5XZi9nOS-Gdfwus,28
|
|
60
|
+
mainsequence-9.0.3.dev33.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|