Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.5.0"
".": "2.6.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 32
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-242450ea46eb8c3e843fd6c4bf87e73192b5f62f6da697cd091d13c6aa7a991b.yml
openapi_spec_hash: c1c561976de1abcacede71fd5ab9b3d9
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-91f4286859fc23813c5255b877395c87dd81520c3913fdfdae3cfa343e1a4873.yml
openapi_spec_hash: 71746b5b65f20617ee021e071d5f7f92
config_hash: 70e7e80b5e87f94981bee396c6cd41e8
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 2.6.0 (2026-07-27)

Full Changelog: [v2.5.0...v2.6.0](https://github.com/context-dot-dev/context-php-sdk/compare/v2.5.0...v2.6.0)

### Features

* **api:** api update ([ead89a6](https://github.com/context-dot-dev/context-php-sdk/commit/ead89a68d802e28bce49e8fbbecd9afbd064abfc))
* **api:** api update ([61f098d](https://github.com/context-dot-dev/context-php-sdk/commit/61f098d3e54db1a7ed6e927cfd0a4b036ceb97c9))

## 2.5.0 (2026-07-22)

Full Changelog: [v2.4.0...v2.5.0](https://github.com/context-dot-dev/context-php-sdk/compare/v2.4.0...v2.5.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The REST API documentation can be found on [docs.context.dev](https://docs.conte
<!-- x-release-please-start-version -->

```
composer require "context-dev/context-dev-php 2.5.0"
composer require "context-dev/context-dev-php 2.6.0"
```

<!-- x-release-please-end -->
Expand Down
106 changes: 50 additions & 56 deletions src/Monitors/MonitorCreateParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
*
* @see ContextDev\Services\MonitorsService::create()
*
* @phpstan-import-type ChangeDetectionVariants from \ContextDev\Monitors\MonitorCreateParams\ChangeDetection
* @phpstan-import-type TargetVariants from \ContextDev\Monitors\MonitorCreateParams\Target
* @phpstan-import-type ChangeDetectionVariants from \ContextDev\Monitors\MonitorCreateParams\ChangeDetection
* @phpstan-import-type TargetShape from \ContextDev\Monitors\MonitorCreateParams\Target
* @phpstan-import-type ChangeDetectionShape from \ContextDev\Monitors\MonitorCreateParams\ChangeDetection
* @phpstan-import-type ScheduleShape from \ContextDev\Monitors\MonitorCreateParams\Schedule
* @phpstan-import-type TargetShape from \ContextDev\Monitors\MonitorCreateParams\Target
* @phpstan-import-type WebhookShape from \ContextDev\Monitors\MonitorCreateParams\Webhook
*
* @phpstan-type MonitorCreateParamsShape = array{
* changeDetection: ChangeDetectionShape,
* name: string,
* schedule: Schedule|ScheduleShape,
* target: TargetShape,
* changeDetection?: ChangeDetectionShape|null,
* mode?: null|Mode|value-of<Mode>,
* schedule?: null|Schedule|ScheduleShape,
* tags?: list<string>|null,
* webhook?: null|Webhook|WebhookShape,
* }
Expand All @@ -48,23 +48,9 @@ final class MonitorCreateParams implements BaseModel
use SdkModel;
use SdkParams;

/**
* Discriminated union describing how changes are detected.
*
* @var ChangeDetectionVariants $changeDetection
*/
#[Required('change_detection', union: ChangeDetection::class)]
public MonitorsExactChangeDetection|MonitorsSemanticChangeDetection $changeDetection;

#[Required]
public string $name;

/**
* Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
*/
#[Required]
public Schedule $schedule;

/**
* Discriminated union describing what the monitor watches.
*
Expand All @@ -73,6 +59,14 @@ final class MonitorCreateParams implements BaseModel
#[Required(union: Target::class)]
public MonitorsPageTarget|MonitorsSitemapTarget|MonitorsExtractTarget $target;

/**
* Discriminated union describing how changes are detected.
*
* @var ChangeDetectionVariants|null $changeDetection
*/
#[Optional('change_detection', union: ChangeDetection::class)]
public MonitorsExactChangeDetection|MonitorsSemanticChangeDetection|null $changeDetection;

/**
* Top-level monitor category. Always `web` today; the concrete behavior is described by `target` and `change_detection`.
*
Expand All @@ -81,6 +75,12 @@ final class MonitorCreateParams implements BaseModel
#[Optional(enum: Mode::class)]
public ?string $mode;

/**
* Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
*/
#[Optional]
public ?Schedule $schedule;

/**
* User-defined tags for grouping and filtering monitors and their changes. Duplicates are removed.
*
Expand All @@ -97,19 +97,13 @@ final class MonitorCreateParams implements BaseModel
*
* To enforce required parameters use
* ```
* MonitorCreateParams::with(
* changeDetection: ..., name: ..., schedule: ..., target: ...
* )
* MonitorCreateParams::with(name: ..., target: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new MonitorCreateParams)
* ->withChangeDetection(...)
* ->withName(...)
* ->withSchedule(...)
* ->withTarget(...)
* (new MonitorCreateParams)->withName(...)->withTarget(...)
* ```
*/
public function __construct()
Expand All @@ -122,50 +116,36 @@ public function __construct()
*
* You must use named parameters to construct any parameters with a default value.
*
* @param ChangeDetectionShape $changeDetection
* @param Schedule|ScheduleShape $schedule
* @param TargetShape $target
* @param ChangeDetectionShape|null $changeDetection
* @param Mode|value-of<Mode>|null $mode
* @param Schedule|ScheduleShape|null $schedule
* @param list<string>|null $tags
* @param Webhook|WebhookShape|null $webhook
*/
public static function with(
MonitorsExactChangeDetection|array|MonitorsSemanticChangeDetection $changeDetection,
string $name,
Schedule|array $schedule,
MonitorsPageTarget|array|MonitorsSitemapTarget|MonitorsExtractTarget $target,
MonitorsExactChangeDetection|array|MonitorsSemanticChangeDetection|null $changeDetection = null,
Mode|string|null $mode = null,
Schedule|array|null $schedule = null,
?array $tags = null,
Webhook|array|null $webhook = null,
): self {
$self = new self;

$self['changeDetection'] = $changeDetection;
$self['name'] = $name;
$self['schedule'] = $schedule;
$self['target'] = $target;

null !== $changeDetection && $self['changeDetection'] = $changeDetection;
null !== $mode && $self['mode'] = $mode;
null !== $schedule && $self['schedule'] = $schedule;
null !== $tags && $self['tags'] = $tags;
null !== $webhook && $self['webhook'] = $webhook;

return $self;
}

/**
* Discriminated union describing how changes are detected.
*
* @param ChangeDetectionShape $changeDetection
*/
public function withChangeDetection(
MonitorsExactChangeDetection|array|MonitorsSemanticChangeDetection $changeDetection,
): self {
$self = clone $this;
$self['changeDetection'] = $changeDetection;

return $self;
}

public function withName(string $name): self
{
$self = clone $this;
Expand All @@ -175,28 +155,29 @@ public function withName(string $name): self
}

/**
* Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
* Discriminated union describing what the monitor watches.
*
* @param Schedule|ScheduleShape $schedule
* @param TargetShape $target
*/
public function withSchedule(Schedule|array $schedule): self
{
public function withTarget(
MonitorsPageTarget|array|MonitorsSitemapTarget|MonitorsExtractTarget $target
): self {
$self = clone $this;
$self['schedule'] = $schedule;
$self['target'] = $target;

return $self;
}

/**
* Discriminated union describing what the monitor watches.
* Discriminated union describing how changes are detected.
*
* @param TargetShape $target
* @param ChangeDetectionShape $changeDetection
*/
public function withTarget(
MonitorsPageTarget|array|MonitorsSitemapTarget|MonitorsExtractTarget $target
public function withChangeDetection(
MonitorsExactChangeDetection|array|MonitorsSemanticChangeDetection $changeDetection,
): self {
$self = clone $this;
$self['target'] = $target;
$self['changeDetection'] = $changeDetection;

return $self;
}
Expand All @@ -214,6 +195,19 @@ public function withMode(Mode|string $mode): self
return $self;
}

/**
* Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
*
* @param Schedule|ScheduleShape $schedule
*/
public function withSchedule(Schedule|array $schedule): self
{
$self = clone $this;
$self['schedule'] = $schedule;

return $self;
}

/**
* User-defined tags for grouping and filtering monitors and their changes. Duplicates are removed.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use ContextDev\Core\Contracts\BaseModel;

/**
* Detect meaning-level changes to tracked page content, ignoring cosmetic or paraphrase-only differences. Which changes are meaningful is judged against the extract target's `instructions` (and `schema`, when provided).
* Detect meaning-level changes to page content, ignoring cosmetic or instruction-irrelevant differences. Which changes are meaningful is judged against the page or extract target's `instructions` (and an extract target's `schema`, when provided).
*
* @phpstan-type MonitorsSemanticChangeDetectionShape = array{
* type: 'semantic', confidenceThreshold?: float|null
Expand Down
26 changes: 24 additions & 2 deletions src/Monitors/MonitorCreateParams/Target/MonitorsPageTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
use ContextDev\Core\Contracts\BaseModel;

/**
* Watch a single web page.
* Watch a single web page. Exact detection reports visible-text diffs; semantic detection judges confirmed stable diffs against `instructions`.
*
* @phpstan-type MonitorsPageTargetShape = array{
* type: 'page', url: string, normalizeWhitespace?: bool|null
* type: 'page',
* url: string,
* instructions?: string|null,
* normalizeWhitespace?: bool|null,
* }
*/
final class MonitorsPageTarget implements BaseModel
Expand All @@ -28,6 +31,12 @@ final class MonitorsPageTarget implements BaseModel
#[Required]
public string $url;

/**
* Plain-language goal describing which page changes matter. When provided without change_detection, semantic detection is inferred.
*/
#[Optional]
public ?string $instructions;

/**
* Normalize whitespace before comparing or analyzing text.
*/
Expand Down Expand Up @@ -60,12 +69,14 @@ public function __construct()
*/
public static function with(
string $url,
?string $instructions = null,
?bool $normalizeWhitespace = null
): self {
$self = new self;

$self['url'] = $url;

null !== $instructions && $self['instructions'] = $instructions;
null !== $normalizeWhitespace && $self['normalizeWhitespace'] = $normalizeWhitespace;

return $self;
Expand All @@ -90,6 +101,17 @@ public function withURL(string $url): self
return $self;
}

/**
* Plain-language goal describing which page changes matter. When provided without change_detection, semantic detection is inferred.
*/
public function withInstructions(string $instructions): self
{
$self = clone $this;
$self['instructions'] = $instructions;

return $self;
}

/**
* Normalize whitespace before comparing or analyzing text.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use ContextDev\Core\Contracts\BaseModel;

/**
* Detect meaning-level changes to tracked page content, ignoring cosmetic or paraphrase-only differences. Which changes are meaningful is judged against the extract target's `instructions` (and `schema`, when provided).
* Detect meaning-level changes to page content, ignoring cosmetic or instruction-irrelevant differences. Which changes are meaningful is judged against the page or extract target's `instructions` (and an extract target's `schema`, when provided).
*
* @phpstan-type MonitorsSemanticChangeDetectionShape = array{
* type: 'semantic', confidenceThreshold?: float|null
Expand Down
26 changes: 24 additions & 2 deletions src/Monitors/MonitorGetResponse/Target/MonitorsPageTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
use ContextDev\Core\Contracts\BaseModel;

/**
* Watch a single web page.
* Watch a single web page. Exact detection reports visible-text diffs; semantic detection judges confirmed stable diffs against `instructions`.
*
* @phpstan-type MonitorsPageTargetShape = array{
* type: 'page', url: string, normalizeWhitespace?: bool|null
* type: 'page',
* url: string,
* instructions?: string|null,
* normalizeWhitespace?: bool|null,
* }
*/
final class MonitorsPageTarget implements BaseModel
Expand All @@ -28,6 +31,12 @@ final class MonitorsPageTarget implements BaseModel
#[Required]
public string $url;

/**
* Plain-language goal describing which page changes matter. When provided without change_detection, semantic detection is inferred.
*/
#[Optional]
public ?string $instructions;

/**
* Normalize whitespace before comparing or analyzing text.
*/
Expand Down Expand Up @@ -60,12 +69,14 @@ public function __construct()
*/
public static function with(
string $url,
?string $instructions = null,
?bool $normalizeWhitespace = null
): self {
$self = new self;

$self['url'] = $url;

null !== $instructions && $self['instructions'] = $instructions;
null !== $normalizeWhitespace && $self['normalizeWhitespace'] = $normalizeWhitespace;

return $self;
Expand All @@ -90,6 +101,17 @@ public function withURL(string $url): self
return $self;
}

/**
* Plain-language goal describing which page changes matter. When provided without change_detection, semantic detection is inferred.
*/
public function withInstructions(string $instructions): self
{
$self = clone $this;
$self['instructions'] = $instructions;

return $self;
}

/**
* Normalize whitespace before comparing or analyzing text.
*/
Expand Down
Loading
Loading